43#include <boost/test/test_tools.hpp>
44#include <boost/test/unit_test.hpp>
118 BOOST_CHECK(temp == obj.
a);
122 BOOST_CHECK(temp == zero);
123 BOOST_CHECK(temp != obj.
a);
131 BOOST_CHECK(const_temp == obj.
a);
132 BOOST_CHECK(const_temp != const_zero);
133 const_temp = const_zero;
134 BOOST_CHECK(const_temp == const_zero);
137 BOOST_CHECK(const_temp == const_zero);
138 BOOST_CHECK(const_temp != obj.
a);
149 BOOST_CHECK(a.begin() == a.end());
150 BOOST_CHECK(b.begin() == b.end());
152 BOOST_CHECK_EQUAL(a.size(), 0);
153 BOOST_CHECK_EQUAL(b.size(), 0);
155 BOOST_CHECK_EQUAL(a.num_dimensions(), 1);
156 BOOST_CHECK_EQUAL(b.num_dimensions(), 1);
166 BOOST_CHECK(a.begin() == a.end());
167 BOOST_CHECK(b.begin() == b.end());
169 BOOST_CHECK_EQUAL(a.size(), 0);
170 BOOST_CHECK_EQUAL(b.size(), 0);
172 BOOST_CHECK_EQUAL(a.num_dimensions(), 2);
173 BOOST_CHECK_EQUAL(b.num_dimensions(), 2);
187 BOOST_CHECK(a.begin() != a.end());
188 BOOST_CHECK(b.begin() != b.end());
190 BOOST_CHECK_EQUAL(a.size(), 5);
191 BOOST_CHECK_EQUAL(b.size(), 10);
193 BOOST_CHECK_EQUAL(a.num_dimensions(), 1);
194 BOOST_CHECK_EQUAL(b.num_dimensions(), 1);
205 BOOST_CHECK(a.begin() != a.end());
206 BOOST_CHECK(b.begin() != b.end());
208 BOOST_CHECK_EQUAL(a.size(), 50);
209 BOOST_CHECK_EQUAL(b.size(), 100);
211 BOOST_CHECK_EQUAL(a.shape()[0], 5);
212 BOOST_CHECK_EQUAL(a.shape()[1], 10);
213 BOOST_CHECK_EQUAL(b.shape()[0], 10);
214 BOOST_CHECK_EQUAL(b.shape()[1], 10);
216 BOOST_CHECK_EQUAL(a.num_dimensions(), 2);
217 BOOST_CHECK_EQUAL(b.num_dimensions(), 2);
232 BOOST_CHECK(a.begin() != a.end());
233 BOOST_CHECK(b.begin() != b.end());
235 BOOST_CHECK_EQUAL(a.size(), 5);
236 BOOST_CHECK_EQUAL(b.size(), 10);
238 BOOST_CHECK_EQUAL(a.num_dimensions(), 1);
239 BOOST_CHECK_EQUAL(b.num_dimensions(), 1);
243 iter != a.end(); ++iter)
245 BOOST_CHECK(*iter == initValue);
249 iter != b.end(); ++iter)
251 BOOST_CHECK(*iter == initValue);
264 BOOST_CHECK(a.begin() != a.end());
265 BOOST_CHECK(b.begin() != b.end());
267 BOOST_CHECK_EQUAL(a.size(), 50);
268 BOOST_CHECK_EQUAL(b.size(), 100);
270 BOOST_CHECK_EQUAL(a.shape()[0], 5);
271 BOOST_CHECK_EQUAL(a.shape()[1], 10);
272 BOOST_CHECK_EQUAL(b.shape()[0], 10);
273 BOOST_CHECK_EQUAL(b.shape()[1], 10);
275 BOOST_CHECK_EQUAL(a.num_dimensions(), 2);
276 BOOST_CHECK_EQUAL(b.num_dimensions(), 2);
279 for (size_type i = 0; i < a.shape()[0]; ++i)
281 for (size_type j = 0; j < a.shape()[1]; ++j)
283 BOOST_CHECK(a[i][j] == initValue);
287 for (size_type i = 0; i < b.shape()[0]; ++i)
289 for (size_type j = 0; j < b.shape()[1]; ++j)
291 BOOST_CHECK(b[i][j] == initValue);
314 BOOST_CHECK(a.begin() != a.end());
315 BOOST_CHECK(b.begin() != b.end());
317 BOOST_CHECK_EQUAL(a.size(), 4);
318 BOOST_CHECK_EQUAL(b.size(), 5);
320 BOOST_CHECK_EQUAL(a.num_dimensions(), 1);
321 BOOST_CHECK_EQUAL(b.num_dimensions(), 1);
324 for (size_type i = 0; i < a.size(); ++i)
326 BOOST_CHECK(a[i] == a_array[i]);
329 for (size_type i = 0; i < b.size(); ++i)
331 BOOST_CHECK(b[i] == b_array[i]);
337 double a_array[] = {1.0, 2.0, 3.0, 4.0};
338 double b_array[] = {5.0, 6.0, 7.0, 8.0, 9.0};
342 BOOST_CHECK(a.size() == 4);
343 BOOST_CHECK(b.size() == 5);
346 for (size_type i = 0; i < a.size(); ++i)
348 BOOST_CHECK(a[i] == a_array[i]);
351 for (size_type i = 0; i < b.size(); ++i)
353 BOOST_CHECK(b[i] == b_array[i]);
379 BOOST_CHECK_EQUAL(c.size(), a.size());
380 BOOST_CHECK_EQUAL(e.size(), a.size());
381 BOOST_CHECK_EQUAL(
d.size(), b.size());
382 BOOST_CHECK(c.data() == a.data());
383 BOOST_CHECK(e.data() == a.data());
384 BOOST_CHECK(
d.data() == b.data());
410 BOOST_CHECK_EQUAL(a_off[0].value, a[1].value);
411 BOOST_CHECK_EQUAL(a_off[1].value, a[2].value);
412 BOOST_CHECK_EQUAL(a_off[2].value, a[3].value);
413 BOOST_CHECK_EQUAL(a_off.size(), 3);
415 BOOST_CHECK_EQUAL(b_off[0].value, b[2].value);
416 BOOST_CHECK_EQUAL(b_off[1].value, b[3].value);
417 BOOST_CHECK_EQUAL(b_off[2].value, b[4].value);
418 BOOST_CHECK_EQUAL(b_off.size(), 3);
420 BOOST_CHECK_EQUAL(bb_off[0].value, b[2].value);
421 BOOST_CHECK_EQUAL(bb_off[1].value, b[3].value);
422 BOOST_CHECK_EQUAL(bb_off[2].value, b[4].value);
423 BOOST_CHECK_EQUAL(bb_off.size(), 3);
449 BOOST_CHECK_EQUAL(lhs_a.size(), 0);
450 BOOST_CHECK_EQUAL(lhs_b1.size(), 0);
451 BOOST_CHECK_EQUAL(lhs_b2.size(), 0);
459 BOOST_CHECK_EQUAL(lhs_a.size(), a.size());
460 BOOST_CHECK_EQUAL(lhs_b1.size(), b.size());
461 BOOST_CHECK_EQUAL(lhs_b2.size(), b.size());
462 BOOST_CHECK_EQUAL(lhs_a.data(), a.data());
463 BOOST_CHECK_EQUAL(lhs_b1.data(), b.data());
464 BOOST_CHECK_EQUAL(lhs_b2.data(), b.data());
467 for (size_type i = 0; i < a.size(); ++i)
469 BOOST_CHECK(lhs_a[i] == a[i]);
472 for (size_type i = 0; i < b.size(); ++i)
474 BOOST_CHECK(lhs_b1[i] == b[i]);
475 BOOST_CHECK(lhs_b2[i] == b[i]);
496 BOOST_CHECK(a.begin() != a.end());
497 BOOST_CHECK(b.begin() != b.end());
499 BOOST_CHECK_EQUAL(a.size(), 50);
500 BOOST_CHECK_EQUAL(b.size(), 100);
501 BOOST_CHECK_EQUAL(a.shape()[0], 5);
502 BOOST_CHECK_EQUAL(a.shape()[1], 10);
503 BOOST_CHECK_EQUAL(b.shape()[0], 10);
504 BOOST_CHECK_EQUAL(b.shape()[1], 10);
506 BOOST_CHECK_EQUAL(a.num_dimensions(), 2);
507 BOOST_CHECK_EQUAL(b.num_dimensions(), 2);
514 BOOST_CHECK_EQUAL(lhs_a.size(), 0);
515 BOOST_CHECK_EQUAL(lhs_b1.size(), 0);
516 BOOST_CHECK_EQUAL(lhs_b2.size(), 0);
523 BOOST_CHECK_EQUAL(lhs_a.size(), a.size());
524 BOOST_CHECK_EQUAL(lhs_b1.size(), b.size());
525 BOOST_CHECK_EQUAL(lhs_b2.size(), b.size());
526 BOOST_CHECK_EQUAL(lhs_a.shape()[0], a.shape()[0]);
527 BOOST_CHECK_EQUAL(lhs_a.shape()[1], a.shape()[1]);
529 BOOST_CHECK_EQUAL(lhs_b1.shape()[0], b.shape()[0]);
530 BOOST_CHECK_EQUAL(lhs_b1.shape()[1], b.shape()[1]);
532 BOOST_CHECK_EQUAL(lhs_b2.shape()[0], b.shape()[0]);
533 BOOST_CHECK_EQUAL(lhs_b2.shape()[1], b.shape()[1]);
536 for (size_type i = 0; i < a.shape()[0]; ++i)
538 for (size_type j = 0; j < a.shape()[1]; ++j)
540 BOOST_CHECK(a[i][j] == initValue);
541 BOOST_CHECK(lhs_a[i][j] == a[i][j]);
545 for (size_type i = 0; i < b.shape()[0]; ++i)
547 for (size_type j = 0; j < b.shape()[1]; ++j)
549 BOOST_CHECK(b[i][j] == initValue);
550 BOOST_CHECK(lhs_b1[i][j] == b[i][j]);
551 BOOST_CHECK(lhs_b2[i][j] == b[i][j]);
563 double a[] = {1.0, 2.0, 3.0, 4.0, 5.0};
564 double b[] = {10.0, 20.0, 30.0, 40.0};
579 BOOST_CHECK_EQUAL(lhs_a.size(), offset_a.size());
580 BOOST_CHECK_EQUAL(lhs_b.size(), offset_b.size());
583 for (size_type i = 0; i < lhs_a.size(); ++i)
585 BOOST_CHECK(lhs_a[i] == offset_a[i]);
588 for (size_type i = 0; i < lhs_b.size(); ++i)
590 BOOST_CHECK(lhs_b[i] == offset_b[i]);
598 double a[] = {1.0, 2.0, 3.0, 4.0, 5.0};
599 double b[] = {10.0, 20.0, 30.0, 40.0};
604 BOOST_CHECK_EQUAL(rhs_a[0], 1.0);
605 BOOST_CHECK_EQUAL(rhs_a[1], 2.0);
606 BOOST_CHECK_EQUAL(rhs_a[2], 3.0);
607 BOOST_CHECK_EQUAL(rhs_a[3], 4.0);
608 BOOST_CHECK_EQUAL(rhs_a[4], 5.0);
610 BOOST_CHECK_EQUAL(rhs_b[0], 10.0);
611 BOOST_CHECK_EQUAL(rhs_b[1], 20.0);
612 BOOST_CHECK_EQUAL(rhs_b[2], 30.0);
613 BOOST_CHECK_EQUAL(rhs_b[3], 40.0);
614#if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULL_DEBUG)
615 BOOST_CHECK_NO_THROW(rhs_a[4]);
617 BOOST_CHECK_NO_THROW(rhs_b[3]);
625 NekDouble a_vals[] = {1.0, 2.0, 3.0, 4.0, 5.0,
626 6.0, 7.0, 8.0, 9.0, 10.0};
629 BOOST_CHECK_EQUAL(a.GetRows(), 5);
630 BOOST_CHECK_EQUAL(a.GetColumns(), 2);
633 for (size_type i = 0; i < a.GetRows(); ++i)
635 for (size_type j = 0; j < a.GetColumns(); ++j)
637 BOOST_CHECK_EQUAL(a[i][j], a_vals[i * a.GetColumns() + j]);
642 NekDouble rhs_vals[] = {18.0, -76.2, 45.2, 1352.246, -46.346,
643 -2463.346, 26.347, 1.0, 0.0, 23465.3};
644 for (size_type i = 0; i < a.GetRows(); ++i)
646 for (size_type j = 0; j < a.GetColumns(); ++j)
648 a[i][j] = rhs_vals[i * a.GetColumns() + j];
652 for (size_type i = 0; i < a.GetRows(); ++i)
654 for (size_type j = 0; j < a.GetColumns(); ++j)
656 BOOST_CHECK_EQUAL(a[i][j], rhs_vals[i * a.GetColumns() + j]);
663 NekDouble a_vals[] = {1.0, 3.0, 5.0, 7.0, 9.0};
665 BOOST_CHECK_EQUAL(a.GetRows(), 5);
666 BOOST_CHECK_EQUAL(a.GetColumns(), 1);
669 for (size_type i = 0; i < a.GetRows(); ++i)
671 BOOST_CHECK_EQUAL(a[i][0], a_vals[i]);
678 BOOST_CHECK_EQUAL(a[0][0], 17.23);
686 using int_type = int;
688 int_type a[] = {1, 2, 3, 4, 5};
695 BOOST_CHECK(nek_a == nek_b);
697 BOOST_CHECK(nek_a == nek_c);
701 BOOST_CHECK(!(nek_a == nek_b));
706 using float_type = double;
708 float_type a[] = {1.0, 2.0, 3.0, 4.0, 5.0};
715 nek_b[3] *= (1.0 + std::numeric_limits<float_type>::epsilon());
716 BOOST_CHECK(nek_a == nek_b);
718 BOOST_CHECK(nek_a == nek_c);
721 nek_b[4] *= (1.0 + 100 * std::numeric_limits<float_type>::epsilon());
722 BOOST_CHECK(!(nek_a == nek_b));
746 using int_type = int;
748 int_type a[] = {1, 2, 3, 4, 5};
754 BOOST_CHECK(nek_a == nek_b);
756 BOOST_CHECK(nek_a == nek_c);
760 BOOST_CHECK(!(nek_a == nek_b));
765 using float_type = double;
767 float_type a[] = {1., 2., 3., 4., 5.};
773 nek_b[3][0] *= (1.0 + std::numeric_limits<float_type>::epsilon());
774 BOOST_CHECK(nek_a == nek_b);
776 BOOST_CHECK(nek_a == nek_c);
779 nek_b[4][0] *= (1.0 + 100 * std::numeric_limits<float_type>::epsilon());
780 BOOST_CHECK(!(nek_a == nek_b));
static void Check(unsigned int expectedDefaultConstructed, unsigned int expectedConstructedFromInt, unsigned int expectedDestroyed, unsigned int expectedCopied, unsigned int expectedCloned, unsigned int expectedAssigned)
static void ClearCounters()
void getConstByReference(Array< OneD, const NekDouble > &out)
void getNonConstByValue(Array< OneD, NekDouble > out)
void getConstByValue(Array< OneD, const NekDouble > out)
void getNonConstByReference(Array< OneD, NekDouble > &out)
Array< OneD, NekDouble > a
Array< OneD, const NekDouble > b
BOOST_AUTO_TEST_CASE(TestArrayConstructionFromConstantArray)
void RedirectCerrIfNeeded()
std::vector< double > d(NPUPPER *NPUPPER)