1 #include <Tpetra_MultiVectorFiller.hpp> 10 using Teuchos::ArrayView;
11 using Tpetra::Details::sortAndMergeIn;
13 Array<int> allEntries (5);
14 for (Array<int>::size_type k = 0; k < 5; ++k) {
15 allEntries[k] = 2 * k;
17 Array<int> newEntries (4);
23 ArrayView<int> result =
24 sortAndMergeIn<int> (allEntries, allEntries.view (0, 5), newEntries());
25 TEUCHOS_TEST_FOR_EXCEPTION(
26 result.size() != 8, std::logic_error,
27 "Returned ArrayView should have size 8, but instead has size " 28 << result.size() <<
".");
29 TEUCHOS_TEST_FOR_EXCEPTION(
30 allEntries.size() < 8, std::logic_error,
31 "Input/output Array argument should have size at least 8, but instead has " 32 "size " << allEntries.size() <<
".");
35 ArrayView<int>::size_type firstBadIndex = -1;
36 for (ArrayView<int>::size_type k = 0; k < result.size(); ++k) {
37 if (result[k] != allEntries[k]) {
43 TEUCHOS_TEST_FOR_EXCEPTION(
44 success, std::logic_error,
"Returned ArrayView and the input/output " 45 "Array argument don't match. First nonmatching array index is " 46 << firstBadIndex <<
".");
48 Array<int> expectedEntries (8);
49 expectedEntries[0] = -1;
50 expectedEntries[1] = 0;
51 expectedEntries[2] = 2;
52 expectedEntries[3] = 3;
53 expectedEntries[4] = 4;
54 expectedEntries[5] = 6;
55 expectedEntries[6] = 8;
56 expectedEntries[7] = 11;
57 for (ArrayView<int>::size_type k = 0; k < result.size(); ++k) {
58 if (expectedEntries[k] != result[k]) {
64 TEUCHOS_TEST_FOR_EXCEPTION(success, std::logic_error,
"Returned ArrayView " 65 "and the expected results don't match. First nonmatching array index is " 66 << firstBadIndex <<
".");
Namespace Tpetra contains the class and methods constituting the Tpetra library.