MyraMath
bounds_Vector


Source: tests/dense/bounds_Vector.cpp

1 // ========================================================================= //
2 // This file is part of MyraMath, copyright (c) 2014-2019 by Ryan A Chilton //
3 // and distributed by MyraCore, LLC. See LICENSE.txt for license terms. //
4 // ========================================================================= //
5 
11 // Containers.
12 #include <myramath/dense/Vector.h>
13 
14 // Reporting.
15 #include <tests/myratest.h>
16 
17 using namespace myra;
18 
19 ADD_TEST("bounds_Vector","[dense]")
20  {
21  // Make random x, access it out of bounds in a variety of ways.
22  auto x = Vector<double>::random(3);
23  // Scalar access using at()
24  REQUIRE_EXCEPTION( auto y = x.at(3); );
25  REQUIRE_EXCEPTION( auto y = x.at(-1); );
26  // Window access.
27  REQUIRE_EXCEPTION( auto y = x.window(-1,0); );
28  REQUIRE_EXCEPTION( auto y = x.window(0,-1); );
29  REQUIRE_EXCEPTION( auto y = x.window(2,4); );
30  REQUIRE_EXCEPTION( auto y = x.window(4,5); );
31  REQUIRE_EXCEPTION( auto y = x.window(2,1); );
32  }
33 
const Number & at(int n) const
Bounds checked random accessor/mutator.
Definition: Vector.cpp:174
static Vector< Number > random(int N)
Generates a random Vector of specified size.
Definition: Vector.cpp:276
Definition: syntax.dox:1
Container for either a column vector or row vector (depends upon the usage context) ...
CVectorRange< Number > window(int n0, int n1) const
Returns a VectorRange over this(n0:n1)
Definition: Vector.cpp:140


Results: [PASS]


Go back to Summary of /test programs.