Debian Codegraph @

packages/stk/stk_unit_tests/stk_util/util/UnitTestSortedContainsAll.cpp

raw
1 // Copyright 2002 - 2008, 2010, 2011 National Technology Engineering
2 // Solutions of Sandia, LLC (NTESS). Under the terms of Contract
3 // DE-NA0003525 with NTESS, the U.S. Government retains certain rights
4 // in this software.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 // * Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following
15 // disclaimer in the documentation and/or other materials provided
16 // with the distribution.
17 //
18 // * Neither the name of NTESS nor the names of its contributors
19 // may be used to endorse or promote products derived from this
20 // software without specific prior written permission.
21 //
22 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
34
35 #include "gtest/gtest.h"
36 #include "stk_util/util/SortedIntersect.hpp"
37 #include "stk_util/util/SortedContains.hpp"
38 #include <vector>
39
40 TEST( SortedContains, bothEmpty)
41 {
42 std::vector<int> sortedSuperset;
43 std::vector<int> sortedSubset;
44
45 EXPECT_TRUE(stk::util::sorted_contains_all(sortedSuperset.begin(), sortedSuperset.end(),
46 sortedSubset.begin(), sortedSubset.end()));
47 }
48
49 TEST( SortedContains, firstEmpty)
50 {
51 std::vector<int> sortedSuperset;
52 std::vector<int> sortedSubset = {1, 2, 3};
53
54 EXPECT_FALSE(stk::util::sorted_contains_all(sortedSuperset.begin(), sortedSuperset.end(),
55 sortedSubset.begin(), sortedSubset.end()));
56 }
57
58 TEST( SortedContains, secondEmpty)
59 {
60 std::vector<int> sortedSuperset = {1, 2, 3};
61 std::vector<int> sortedSubset;
62
63 EXPECT_TRUE(stk::util::sorted_contains_all(sortedSuperset.begin(), sortedSuperset.end(),
64 sortedSubset.begin(), sortedSubset.end()));
65 }
66
67 TEST( SortedContains, firstFoundInSecond)
68 {
69 std::vector<int> sortedSuperset = {1, 2};
70 std::vector<int> sortedSubset = {0, 1, 3, 5};
71
72 EXPECT_FALSE(stk::util::sorted_contains_all(sortedSuperset.begin(), sortedSuperset.end(),
73 sortedSubset.begin(), sortedSubset.end()));
74 }
75
76 TEST( SortedContains, firstEndSmallerThanSecondBegin)
77 {
78 std::vector<int> sortedSuperset = {1, 2};
79 std::vector<int> sortedSubset = {3, 4, 5, 6};
80
81 EXPECT_FALSE(stk::util::sorted_contains_all(sortedSuperset.begin(), sortedSuperset.end(),
82 sortedSubset.begin(), sortedSubset.end()));
83 }
84
85 TEST( SortedContains, firstBeginBiggerThanSecondEnd)
86 {
87 std::vector<int> sortedSuperset = {3, 4, 5, 6};
88 std::vector<int> sortedSubset = {1, 2};
89
90 EXPECT_FALSE(stk::util::sorted_contains_all(sortedSuperset.begin(), sortedSuperset.end(),
91 sortedSubset.begin(), sortedSubset.end()));
92 }
93
94 TEST( SortedContains, firstContainsSecond)
95 {
96 std::vector<int> sortedSuperset = {1, 2, 3, 4, 5, 6};
97 std::vector<int> sortedSubset = {2, 3};
98
99 EXPECT_TRUE(stk::util::sorted_contains_all(sortedSuperset.begin(), sortedSuperset.end(),
100 sortedSubset.begin(), sortedSubset.end()));
101 }
102
103 TEST( SortedContains, firstEqualsSecond)
104 {
105 std::vector<int> sortedSuperset = {1, 2, 3, 4, 5, 6};
106 std::vector<int> sortedSubset = {1, 2, 3, 4, 5, 6};
107
108 EXPECT_TRUE(stk::util::sorted_contains_all(sortedSuperset.begin(), sortedSuperset.end(),
109 sortedSubset.begin(), sortedSubset.end()));
110 }
111