Nektar++
Classes | Functions
Nektar::SharedArrayUnitTests Namespace Reference

Classes

class  ParameterTestClass
 

Functions

 BOOST_AUTO_TEST_CASE (TestArrayConstructionFromConstantArray)
 
 BOOST_AUTO_TEST_CASE (TestArrayWapper)
 
void CheckAddresses (Array< TwoD, double >::reference d, double *expectedAddress)
 
 BOOST_AUTO_TEST_CASE (TestRowPointers)
 
 BOOST_AUTO_TEST_CASE (TestParameterPopulation)
 
 BOOST_AUTO_TEST_CASE (TestEmptyConstructor)
 
 BOOST_AUTO_TEST_CASE (TestUninitializedConstructor)
 
 BOOST_AUTO_TEST_CASE (TestSingleValueInitialization)
 
 BOOST_AUTO_TEST_CASE (TestPopulationFromCArray)
 
 BOOST_AUTO_TEST_CASE (TestCopyConstruction)
 
 BOOST_AUTO_TEST_CASE (Test1DAssignmentOperator)
 
 BOOST_AUTO_TEST_CASE (Test2DAssignmentOperator)
 
 BOOST_AUTO_TEST_CASE (TestOffsetAssignmentOperator)
 
 BOOST_AUTO_TEST_CASE (Test1DAccessOperator)
 
 BOOST_AUTO_TEST_CASE (Test2DAccessOperator)
 
 BOOST_AUTO_TEST_CASE (Test1DEqualOperator)
 
 BOOST_AUTO_TEST_CASE (Test2DEqualOperator)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( Test1DAccessOperator  )

Definition at line 594 of file testNekSharedArray.cpp.

595{
597 // Normal access.
598 double a[] = {1.0, 2.0, 3.0, 4.0, 5.0};
599 double b[] = {10.0, 20.0, 30.0, 40.0};
600
601 Array<OneD, NekDouble> rhs_a(5, a);
602 Array<OneD, const NekDouble> rhs_b(4, b);
603
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);
609
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]);
616 BOOST_CHECK_THROW(rhs_a[5], ErrorUtil::NekError);
617 BOOST_CHECK_NO_THROW(rhs_b[3]);
618 BOOST_CHECK_THROW(rhs_b[4], ErrorUtil::NekError);
619#endif
620}
Nektar::ErrorUtil::NekError NekError
void RedirectCerrIfNeeded()
Definition: util.cpp:41

References Nektar::UnitTests::RedirectCerrIfNeeded().

◆ BOOST_AUTO_TEST_CASE() [2/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( Test1DAssignmentOperator  )

Definition at line 427 of file testNekSharedArray.cpp.

428{
429 {
430 // 1D
431 CountedObject<double> a_array[] = {
434 CountedObject<double> b_array[] = {
438 CountedObject<double>::ClearCounters();
439 Array<OneD, const CountedObject<double>> a(4, a_array);
440 Array<OneD, CountedObject<double>> b(5, b_array);
441 CountedObject<double>::Check(0, 0, 0, 9, 0, 0);
442
443 {
444 Array<OneD, const CountedObject<double>> lhs_a;
445 Array<OneD, CountedObject<double>> lhs_b1;
446 Array<OneD, const CountedObject<double>> lhs_b2;
447 CountedObject<double>::Check(0, 0, 0, 9, 0, 0);
448
449 BOOST_CHECK_EQUAL(lhs_a.size(), 0);
450 BOOST_CHECK_EQUAL(lhs_b1.size(), 0);
451 BOOST_CHECK_EQUAL(lhs_b2.size(), 0);
452
453 {
454 lhs_a = a;
455 lhs_b1 = b;
456 lhs_b2 = b;
457 CountedObject<double>::Check(0, 0, 0, 9, 0, 0);
458
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());
465
466 using size_type = Array<OneD, double>::size_type;
467 for (size_type i = 0; i < a.size(); ++i)
468 {
469 BOOST_CHECK(lhs_a[i] == a[i]);
470 }
471
472 for (size_type i = 0; i < b.size(); ++i)
473 {
474 BOOST_CHECK(lhs_b1[i] == b[i]);
475 BOOST_CHECK(lhs_b2[i] == b[i]);
476 }
477 CountedObject<double>::Check(0, 0, 0, 9, 0, 0);
478 }
479 CountedObject<double>::Check(0, 0, 0, 9, 0, 0);
480 }
481 CountedObject<double>::Check(0, 0, 0, 9, 0, 0);
482 }
483}

References Nektar::CountedObject< DerivedType >::Check(), and Nektar::CountedObject< DerivedType >::ClearCounters().

◆ BOOST_AUTO_TEST_CASE() [3/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( Test1DEqualOperator  )

Definition at line 682 of file testNekSharedArray.cpp.

683{
684 {
685 // integer types
686 using int_type = int;
687
688 int_type a[] = {1, 2, 3, 4, 5};
689
690 Array<OneD, int_type> nek_a(5, a);
691 Array<OneD, int_type> nek_b(5, a);
692 Array<OneD, const int_type> nek_c(5, a);
693
694 // still equal
695 BOOST_CHECK(nek_a == nek_b);
696 // equal and only one const
697 BOOST_CHECK(nek_a == nek_c);
698
699 // not equal
700 nek_b[3] += 1;
701 BOOST_CHECK(!(nek_a == nek_b));
702 }
703
704 {
705 // float types
706 using float_type = double;
707
708 float_type a[] = {1.0, 2.0, 3.0, 4.0, 5.0};
709
710 Array<OneD, float_type> nek_a(5, a);
711 Array<OneD, float_type> nek_b(5, a);
712 Array<OneD, const float_type> nek_c(5, a);
713
714 // still equal
715 nek_b[3] *= (1.0 + std::numeric_limits<float_type>::epsilon());
716 BOOST_CHECK(nek_a == nek_b);
717 // equal and only one const
718 BOOST_CHECK(nek_a == nek_c);
719
720 // not equal
721 nek_b[4] *= (1.0 + 100 * std::numeric_limits<float_type>::epsilon());
722 BOOST_CHECK(!(nek_a == nek_b));
723 }
724
725 // This should not compile
726 // {
727 // // mixed types should not compare
728 // using float_type = double;
729 // using int_type = int;
730
731 // float_type a[] = {1.0, 2.0, 3.0, 4.0, 5.0};
732 // int_type b[] = {1, 2, 3, 4, 5};
733
734 // Array<OneD, float_type> nek_a(5, a);
735 // Array<OneD, int_type> nek_b(5, b);
736
737 // // still equal
738 // BOOST_CHECK(nek_a == nek_b);
739 // }
740}

◆ BOOST_AUTO_TEST_CASE() [4/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( Test2DAccessOperator  )

Definition at line 622 of file testNekSharedArray.cpp.

623{
624 {
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};
627 Array<TwoD, NekDouble> a(5, 2, a_vals);
628
629 BOOST_CHECK_EQUAL(a.GetRows(), 5);
630 BOOST_CHECK_EQUAL(a.GetColumns(), 2);
631
632 using size_type = Array<TwoD, double>::size_type;
633 for (size_type i = 0; i < a.GetRows(); ++i)
634 {
635 for (size_type j = 0; j < a.GetColumns(); ++j)
636 {
637 BOOST_CHECK_EQUAL(a[i][j], a_vals[i * a.GetColumns() + j]);
638 }
639 }
640
641 // Now test assignment.
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)
645 {
646 for (size_type j = 0; j < a.GetColumns(); ++j)
647 {
648 a[i][j] = rhs_vals[i * a.GetColumns() + j];
649 }
650 }
651
652 for (size_type i = 0; i < a.GetRows(); ++i)
653 {
654 for (size_type j = 0; j < a.GetColumns(); ++j)
655 {
656 BOOST_CHECK_EQUAL(a[i][j], rhs_vals[i * a.GetColumns() + j]);
657 }
658 }
659 }
660
661 {
662 // Test 1 Column.
663 NekDouble a_vals[] = {1.0, 3.0, 5.0, 7.0, 9.0};
664 Array<TwoD, NekDouble> a(5, 1, a_vals);
665 BOOST_CHECK_EQUAL(a.GetRows(), 5);
666 BOOST_CHECK_EQUAL(a.GetColumns(), 1);
667
668 using size_type = Array<TwoD, double>::size_type;
669 for (size_type i = 0; i < a.GetRows(); ++i)
670 {
671 BOOST_CHECK_EQUAL(a[i][0], a_vals[i]);
672 }
673 }
674
675 {
676 Array<TwoD, NekDouble> a(1, 1);
677 a[0][0] = 17.23;
678 BOOST_CHECK_EQUAL(a[0][0], 17.23);
679 }
680}
double NekDouble

◆ BOOST_AUTO_TEST_CASE() [5/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( Test2DAssignmentOperator  )

Definition at line 485 of file testNekSharedArray.cpp.

486{
487 {
488 // 2D
489 CountedObject<double> initValue(98);
491
492 Array<TwoD, const CountedObject<double>> a(5, 10, initValue);
493 Array<TwoD, CountedObject<double>> b(10, 10, initValue);
494 CountedObject<double>::Check(0, 0, 0, 150, 0, 0);
495
496 BOOST_CHECK(a.begin() != a.end());
497 BOOST_CHECK(b.begin() != b.end());
498
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);
505
506 BOOST_CHECK_EQUAL(a.num_dimensions(), 2);
507 BOOST_CHECK_EQUAL(b.num_dimensions(), 2);
508
509 {
513
514 BOOST_CHECK_EQUAL(lhs_a.size(), 0);
515 BOOST_CHECK_EQUAL(lhs_b1.size(), 0);
516 BOOST_CHECK_EQUAL(lhs_b2.size(), 0);
517
518 lhs_a = a;
519 lhs_b1 = b;
520 lhs_b2 = b;
521 CountedObject<double>::Check(0, 0, 0, 150, 0, 0);
522
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]);
528
529 BOOST_CHECK_EQUAL(lhs_b1.shape()[0], b.shape()[0]);
530 BOOST_CHECK_EQUAL(lhs_b1.shape()[1], b.shape()[1]);
531
532 BOOST_CHECK_EQUAL(lhs_b2.shape()[0], b.shape()[0]);
533 BOOST_CHECK_EQUAL(lhs_b2.shape()[1], b.shape()[1]);
534
535 using size_type = Array<TwoD, double>::size_type;
536 for (size_type i = 0; i < a.shape()[0]; ++i)
537 {
538 for (size_type j = 0; j < a.shape()[1]; ++j)
539 {
540 BOOST_CHECK(a[i][j] == initValue);
541 BOOST_CHECK(lhs_a[i][j] == a[i][j]);
542 }
543 }
544
545 for (size_type i = 0; i < b.shape()[0]; ++i)
546 {
547 for (size_type j = 0; j < b.shape()[1]; ++j)
548 {
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]);
552 }
553 }
554 }
555 CountedObject<double>::Check(0, 0, 0, 150, 0, 0);
556 }
557
558 CountedObject<double>::Check(0, 0, 151, 150, 0, 0);
559}

References Nektar::CountedObject< DerivedType >::Check(), and Nektar::CountedObject< DerivedType >::ClearCounters().

◆ BOOST_AUTO_TEST_CASE() [6/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( Test2DEqualOperator  )

Definition at line 742 of file testNekSharedArray.cpp.

743{
744 {
745 // integer types
746 using int_type = int;
747
748 int_type a[] = {1, 2, 3, 4, 5};
749 Array<TwoD, int_type> nek_a(5, 1, a);
750 Array<TwoD, int_type> nek_b(5, 1, a);
751 Array<TwoD, const int_type> nek_c(5, 1, a);
752
753 // still equal
754 BOOST_CHECK(nek_a == nek_b);
755 // equal and only one const
756 BOOST_CHECK(nek_a == nek_c);
757
758 // not equal
759 nek_b[3][0] += 1;
760 BOOST_CHECK(!(nek_a == nek_b));
761 }
762
763 {
764 // floating types
765 using float_type = double;
766
767 float_type a[] = {1., 2., 3., 4., 5.};
768 Array<TwoD, float_type> nek_a(5, 1, a);
769 Array<TwoD, float_type> nek_b(5, 1, a);
770 Array<TwoD, const float_type> nek_c(5, 1, a);
771
772 // still equal
773 nek_b[3][0] *= (1.0 + std::numeric_limits<float_type>::epsilon());
774 BOOST_CHECK(nek_a == nek_b);
775 // equal and only one const
776 BOOST_CHECK(nek_a == nek_c);
777
778 // not equal
779 nek_b[4][0] *= (1.0 + 100 * std::numeric_limits<float_type>::epsilon());
780 BOOST_CHECK(!(nek_a == nek_b));
781 }
782}

◆ BOOST_AUTO_TEST_CASE() [7/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( TestArrayConstructionFromConstantArray  )

Definition at line 42 of file TestSharedArray.cpp.

43{
44 Array<OneD, const double> const_array_1(10, 7.0);
45 Array<OneD, const double> const_array_2(10, 3.0);
46
47 Array<OneD, double> array_1(const_array_1);
48 Array<OneD, double> array_2(5, const_array_2);
49
50 BOOST_CHECK_EQUAL(array_1.size(), const_array_1.size());
51 BOOST_CHECK_EQUAL(array_2.size(), 5);
52
53 array_1[2] = -1.0;
54 array_2[2] = -1.0;
55
56 BOOST_CHECK_EQUAL(array_1[2], -1.0);
57 BOOST_CHECK_EQUAL(array_2[2], -1.0);
58
59 BOOST_CHECK_EQUAL(const_array_1[2], 7.0);
60 BOOST_CHECK_EQUAL(const_array_2[2], 3.0);
61}

◆ BOOST_AUTO_TEST_CASE() [8/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( TestArrayWapper  )

Definition at line 63 of file TestSharedArray.cpp.

64{
65 // create a array
66 Array<OneD, double> array_1(10, 7.0);
67 {
68 // create a array wrapper
69 Array<OneD, double> array_wrapper_1(array_1.size(), array_1.data(),
71 // check size and value
72 BOOST_CHECK_EQUAL(array_wrapper_1.size(), array_1.size());
73 BOOST_CHECK_EQUAL(array_wrapper_1[0], 7.0);
74 // modify via wrapper
75 array_wrapper_1[0] = -1.0;
76 // check that the original array is modified as well
77 BOOST_CHECK_EQUAL(array_1[0], -1.0);
78 }
79 {
80 // create a array copy
81 Array<OneD, double> array_copy_1(array_1.size(), array_1.data(),
83 // check size and value
84 BOOST_CHECK_EQUAL(array_copy_1.size(), array_1.size());
85 BOOST_CHECK_EQUAL(array_copy_1[1], 7.0);
86 // modify via copy
87 array_copy_1[1] = 0.0;
88 // check that the original array is not modified
89 BOOST_CHECK_EQUAL(array_1[1], 7.0);
90 }
91}

References Nektar::eArrayCopy, and Nektar::eArrayWrapper.

◆ BOOST_AUTO_TEST_CASE() [9/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( TestCopyConstruction  )

Definition at line 358 of file testNekSharedArray.cpp.

359{
360 {
361 CountedObject<double> a_array[] = {
364 CountedObject<double> b_array[] = {
368 CountedObject<double>::ClearCounters();
369
370 Array<OneD, const CountedObject<double>> a(4, a_array);
371 Array<OneD, CountedObject<double>> b(5, b_array);
372 CountedObject<double>::Check(0, 0, 0, 9, 0, 0);
373
374 {
375 Array<OneD, const CountedObject<double>> c(a);
376 Array<OneD, CountedObject<double>> d(b);
377 Array<OneD, const CountedObject<double>> e(a);
378
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());
385
386 CountedObject<double>::Check(0, 0, 0, 9, 0, 0);
387 }
388 CountedObject<double>::Check(0, 0, 0, 9, 0, 0);
389 }
390 CountedObject<double>::Check(0, 0, 18, 9, 0, 0);
391
392 {
393 // Test offset copy constructor.
394 CountedObject<double> a_array[] = {
395 CountedObject<double>(1), CountedObject<double>(2),
396 CountedObject<double>(3), CountedObject<double>(4)};
397 CountedObject<double> b_array[] = {
398 CountedObject<double>(1), CountedObject<double>(2),
399 CountedObject<double>(3), CountedObject<double>(4),
400 CountedObject<double>(5)};
401 CountedObject<double>::ClearCounters();
402 Array<OneD, const CountedObject<double>> a(4, a_array);
403 Array<OneD, CountedObject<double>> b(5, b_array);
404 CountedObject<double>::Check(0, 0, 0, 9, 0, 0);
405
406 Array<OneD, const CountedObject<double>> a_off = a + 1;
407 Array<OneD, const CountedObject<double>> bb_off = b + 2;
408 Array<OneD, CountedObject<double>> b_off = b + 2;
409
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);
414
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);
419
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);
424 }
425}
std::vector< double > d(NPUPPER *NPUPPER)

References Nektar::CountedObject< DerivedType >::Check(), Nektar::CountedObject< DerivedType >::ClearCounters(), and Nektar::UnitTests::d().

◆ BOOST_AUTO_TEST_CASE() [10/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( TestEmptyConstructor  )

Definition at line 141 of file testNekSharedArray.cpp.

142{
143 {
147 CountedObject<double>::Check(0, 0, 0, 0, 0, 0);
148
149 BOOST_CHECK(a.begin() == a.end());
150 BOOST_CHECK(b.begin() == b.end());
151
152 BOOST_CHECK_EQUAL(a.size(), 0);
153 BOOST_CHECK_EQUAL(b.size(), 0);
154
155 BOOST_CHECK_EQUAL(a.num_dimensions(), 1);
156 BOOST_CHECK_EQUAL(b.num_dimensions(), 1);
157 }
158 CountedObject<double>::Check(0, 0, 0, 0, 0, 0);
159
160 {
164 CountedObject<double>::Check(0, 0, 0, 0, 0, 0);
165
166 BOOST_CHECK(a.begin() == a.end());
167 BOOST_CHECK(b.begin() == b.end());
168
169 BOOST_CHECK_EQUAL(a.size(), 0);
170 BOOST_CHECK_EQUAL(b.size(), 0);
171
172 BOOST_CHECK_EQUAL(a.num_dimensions(), 2);
173 BOOST_CHECK_EQUAL(b.num_dimensions(), 2);
174 }
175 CountedObject<double>::Check(0, 0, 0, 0, 0, 0);
176}

References Nektar::CountedObject< DerivedType >::Check(), and Nektar::CountedObject< DerivedType >::ClearCounters().

◆ BOOST_AUTO_TEST_CASE() [11/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( TestOffsetAssignmentOperator  )

Definition at line 561 of file testNekSharedArray.cpp.

562{
563 double a[] = {1.0, 2.0, 3.0, 4.0, 5.0};
564 double b[] = {10.0, 20.0, 30.0, 40.0};
565
566 Array<OneD, NekDouble> rhs_a(5, a);
567 Array<OneD, const NekDouble> rhs_b(4, b);
568
569 Array<OneD, NekDouble> offset_a = rhs_a + 2;
570 ;
571 Array<OneD, const NekDouble> offset_b = rhs_a + 2;
572
573 Array<OneD, NekDouble> lhs_a;
574 Array<OneD, const NekDouble> lhs_b;
575
576 lhs_a = offset_a;
577 lhs_b = offset_b;
578
579 BOOST_CHECK_EQUAL(lhs_a.size(), offset_a.size());
580 BOOST_CHECK_EQUAL(lhs_b.size(), offset_b.size());
581
582 using size_type = Array<TwoD, double>::size_type;
583 for (size_type i = 0; i < lhs_a.size(); ++i)
584 {
585 BOOST_CHECK(lhs_a[i] == offset_a[i]);
586 }
587
588 for (size_type i = 0; i < lhs_b.size(); ++i)
589 {
590 BOOST_CHECK(lhs_b[i] == offset_b[i]);
591 }
592}

◆ BOOST_AUTO_TEST_CASE() [12/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( TestParameterPopulation  )

Definition at line 108 of file testNekSharedArray.cpp.

109{
111
112 Array<OneD, NekDouble> zero(5, 0.0);
113 Array<OneD, NekDouble> temp(zero);
114 Array<OneD, const NekDouble> const_zero(5, 0.0);
115 Array<OneD, const NekDouble> const_temp(const_zero);
116
117 obj.getNonConstByReference(temp);
118 BOOST_CHECK(temp == obj.a);
119
120 temp = zero;
121 obj.getNonConstByValue(temp);
122 BOOST_CHECK(temp == zero);
123 BOOST_CHECK(temp != obj.a);
124
125 // should not compile.
126 // obj.getNonConstByReference(const_temp);
127 // obj.getNonConstByValue(const_temp);
128
129 // Now the ConstArray versions.
130 obj.getConstByReference(const_temp);
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);
135
136 obj.getConstByValue(const_temp);
137 BOOST_CHECK(const_temp == const_zero);
138 BOOST_CHECK(const_temp != obj.a);
139}
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)

References Nektar::SharedArrayUnitTests::ParameterTestClass::a, Nektar::SharedArrayUnitTests::ParameterTestClass::getConstByReference(), Nektar::SharedArrayUnitTests::ParameterTestClass::getConstByValue(), Nektar::SharedArrayUnitTests::ParameterTestClass::getNonConstByReference(), and Nektar::SharedArrayUnitTests::ParameterTestClass::getNonConstByValue().

◆ BOOST_AUTO_TEST_CASE() [13/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( TestPopulationFromCArray  )

Definition at line 298 of file testNekSharedArray.cpp.

299{
300 {
301 CountedObject<double> a_array[] = {
304 CountedObject<double> b_array[] = {
308 CountedObject<double>::ClearCounters();
309
310 Array<OneD, const CountedObject<double>> a(4, a_array);
311 Array<OneD, CountedObject<double>> b(5, b_array);
312 CountedObject<double>::Check(0, 0, 0, 9, 0, 0);
313
314 BOOST_CHECK(a.begin() != a.end());
315 BOOST_CHECK(b.begin() != b.end());
316
317 BOOST_CHECK_EQUAL(a.size(), 4);
318 BOOST_CHECK_EQUAL(b.size(), 5);
319
320 BOOST_CHECK_EQUAL(a.num_dimensions(), 1);
321 BOOST_CHECK_EQUAL(b.num_dimensions(), 1);
322
323 using size_type = Array<OneD, double>::size_type;
324 for (size_type i = 0; i < a.size(); ++i)
325 {
326 BOOST_CHECK(a[i] == a_array[i]);
327 }
328
329 for (size_type i = 0; i < b.size(); ++i)
330 {
331 BOOST_CHECK(b[i] == b_array[i]);
332 }
333 }
334 CountedObject<double>::Check(0, 0, 18, 9, 0, 0);
335
336 {
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};
339 Array<OneD, double> a(4, a_array);
340 Array<OneD, double> b(5, b_array);
341
342 BOOST_CHECK(a.size() == 4);
343 BOOST_CHECK(b.size() == 5);
344
345 using size_type = Array<OneD, double>::size_type;
346 for (size_type i = 0; i < a.size(); ++i)
347 {
348 BOOST_CHECK(a[i] == a_array[i]);
349 }
350
351 for (size_type i = 0; i < b.size(); ++i)
352 {
353 BOOST_CHECK(b[i] == b_array[i]);
354 }
355 }
356}

References Nektar::CountedObject< DerivedType >::Check(), and Nektar::CountedObject< DerivedType >::ClearCounters().

◆ BOOST_AUTO_TEST_CASE() [14/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( TestRowPointers  )

Definition at line 99 of file TestSharedArray.cpp.

100{
101 Array<TwoD, double> array_1(10, 7, 0.0);
102 CheckAddresses(array_1[0], array_1.data());
103 CheckAddresses(array_1[1], array_1.data() + 7);
104}
void CheckAddresses(Array< TwoD, double >::reference d, double *expectedAddress)

References CheckAddresses().

◆ BOOST_AUTO_TEST_CASE() [15/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( TestSingleValueInitialization  )

Definition at line 222 of file testNekSharedArray.cpp.

223{
224 {
225 CountedObject<double> initValue(98);
227
229 Array<OneD, CountedObject<double>> b(10, initValue);
230 CountedObject<double>::Check(0, 0, 0, 15, 0, 0);
231
232 BOOST_CHECK(a.begin() != a.end());
233 BOOST_CHECK(b.begin() != b.end());
234
235 BOOST_CHECK_EQUAL(a.size(), 5);
236 BOOST_CHECK_EQUAL(b.size(), 10);
237
238 BOOST_CHECK_EQUAL(a.num_dimensions(), 1);
239 BOOST_CHECK_EQUAL(b.num_dimensions(), 1);
240
241 for (Array<OneD, const CountedObject<double>>::const_iterator iter =
242 a.begin();
243 iter != a.end(); ++iter)
244 {
245 BOOST_CHECK(*iter == initValue);
246 }
247
248 for (Array<OneD, CountedObject<double>>::iterator iter = b.begin();
249 iter != b.end(); ++iter)
250 {
251 BOOST_CHECK(*iter == initValue);
252 }
253 }
254 CountedObject<double>::Check(0, 0, 16, 15, 0, 0);
255
256 {
257 CountedObject<double> initValue(98);
258 CountedObject<double>::ClearCounters();
259
260 Array<TwoD, const CountedObject<double>> a(5, 10, initValue);
261 Array<TwoD, CountedObject<double>> b(10, 10, initValue);
262 CountedObject<double>::Check(0, 0, 0, 150, 0, 0);
263
264 BOOST_CHECK(a.begin() != a.end());
265 BOOST_CHECK(b.begin() != b.end());
266
267 BOOST_CHECK_EQUAL(a.size(), 50);
268 BOOST_CHECK_EQUAL(b.size(), 100);
269
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);
274
275 BOOST_CHECK_EQUAL(a.num_dimensions(), 2);
276 BOOST_CHECK_EQUAL(b.num_dimensions(), 2);
277
278 using size_type = Array<TwoD, double>::size_type;
279 for (size_type i = 0; i < a.shape()[0]; ++i)
280 {
281 for (size_type j = 0; j < a.shape()[1]; ++j)
282 {
283 BOOST_CHECK(a[i][j] == initValue);
284 }
285 }
286
287 for (size_type i = 0; i < b.shape()[0]; ++i)
288 {
289 for (size_type j = 0; j < b.shape()[1]; ++j)
290 {
291 BOOST_CHECK(b[i][j] == initValue);
292 }
293 }
294 }
295 CountedObject<double>::Check(0, 0, 151, 150, 0, 0);
296}

References Nektar::CountedObject< DerivedType >::Check(), and Nektar::CountedObject< DerivedType >::ClearCounters().

◆ BOOST_AUTO_TEST_CASE() [16/16]

Nektar::SharedArrayUnitTests::BOOST_AUTO_TEST_CASE ( TestUninitializedConstructor  )

Definition at line 178 of file testNekSharedArray.cpp.

179{
180 {
182
185 CountedObject<double>::Check(15, 0, 0, 0, 0, 0);
186
187 BOOST_CHECK(a.begin() != a.end());
188 BOOST_CHECK(b.begin() != b.end());
189
190 BOOST_CHECK_EQUAL(a.size(), 5);
191 BOOST_CHECK_EQUAL(b.size(), 10);
192
193 BOOST_CHECK_EQUAL(a.num_dimensions(), 1);
194 BOOST_CHECK_EQUAL(b.num_dimensions(), 1);
195 }
196 CountedObject<double>::Check(15, 0, 15, 0, 0, 0);
197
198 {
200
203 CountedObject<double>::Check(150, 0, 0, 0, 0, 0);
204
205 BOOST_CHECK(a.begin() != a.end());
206 BOOST_CHECK(b.begin() != b.end());
207
208 BOOST_CHECK_EQUAL(a.size(), 50);
209 BOOST_CHECK_EQUAL(b.size(), 100);
210
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);
215
216 BOOST_CHECK_EQUAL(a.num_dimensions(), 2);
217 BOOST_CHECK_EQUAL(b.num_dimensions(), 2);
218 }
219 CountedObject<double>::Check(150, 0, 150, 0, 0, 0);
220}

References Nektar::CountedObject< DerivedType >::Check(), and Nektar::CountedObject< DerivedType >::ClearCounters().

◆ CheckAddresses()

void Nektar::SharedArrayUnitTests::CheckAddresses ( Array< TwoD, double >::reference  d,
double *  expectedAddress 
)

Definition at line 93 of file TestSharedArray.cpp.

94{
95 BOOST_CHECK_EQUAL(d.size(), 7);
96 BOOST_CHECK_EQUAL(d.origin(), expectedAddress);
97}

References Nektar::UnitTests::d().

Referenced by BOOST_AUTO_TEST_CASE().