20 #include <gtest/gtest.h> 27 const int kSequenceAInt[] = {4, 3, 5};
28 const int kSequenceBInt[] = {-2, 3, 5, 4};
29 const int kSequenceCInt[] = {5, -2, 4, 3, 4, 5, 3};
30 const int kSequenceDInt[] = {-2, 3};
31 const std::string kSequenceAStr =
"acegm";
32 const std::string kSequenceBStr =
"xacvgeze";
33 const std::string kSequenceCStr =
"axaemgccvgeze";
35 typedef std::vector<int> Container;
36 typedef Container::value_type Value;
37 typedef Container::iterator IT;
42 TEST(TestIsInterleaved, Interleaved)
46 Container empty = Container();
47 EXPECT_TRUE(IsInterleaved<IT>
48 (empty.begin(), empty.end(), empty.begin(), empty.end(), empty.begin(), empty.end()));
53 Container sequenceA(kSequenceAInt, kSequenceAInt +
sizeof(kSequenceAInt) /
sizeof(Value));
54 EXPECT_TRUE(IsInterleaved<IT>(sequenceA.begin(), sequenceA.end(), sequenceA.end(),
55 sequenceA.end(), sequenceA.begin(), sequenceA.end()));
60 Container sequenceA(kSequenceAInt, kSequenceAInt +
sizeof(kSequenceAInt) /
sizeof(Value));
61 EXPECT_TRUE(IsInterleaved<IT>(sequenceA.end(), sequenceA.end(), sequenceA.begin(),
62 sequenceA.end(), sequenceA.begin(), sequenceA.end()));
67 Container sequenceA(kSequenceAInt, kSequenceAInt +
sizeof(kSequenceAInt) /
sizeof(Value));
68 EXPECT_FALSE(IsInterleaved<IT>(sequenceA.begin(), sequenceA.end(), sequenceA.begin(),
69 sequenceA.end(), sequenceA.begin(), sequenceA.end()));
74 Container sequenceA(kSequenceAInt, kSequenceAInt +
sizeof(kSequenceAInt) /
sizeof(Value));
75 Container sequenceB(kSequenceBInt, kSequenceBInt +
sizeof(kSequenceBInt) /
sizeof(Value));
76 Container sequenceC(kSequenceCInt, kSequenceCInt +
sizeof(kSequenceCInt) /
sizeof(Value));
77 EXPECT_TRUE(IsInterleaved<IT>(sequenceA.begin(), sequenceA.end(), sequenceB.begin(),
78 sequenceB.end(), sequenceC.begin(), sequenceC.end()));
83 std::string aStr = kSequenceAStr;
84 std::string bStr = kSequenceBStr;
85 std::string cStr = kSequenceCStr;
86 EXPECT_TRUE(IsInterleaved<std::string::iterator>(aStr.begin(), aStr.end(), bStr.begin(),
87 bStr.end(), cStr.begin(), cStr.end()));
92 std::string aStr = kSequenceAStr;
93 std::string bStr = kSequenceBStr;
94 std::string cStr = kSequenceCStr +
'a';
95 EXPECT_FALSE(IsInterleaved<std::string::iterator>(aStr.begin(), aStr.end(), bStr.begin(),
96 bStr.end(), cStr.begin(), cStr.end()));
TEST(TestIsInterleaved, Interleaved)