TestIsInterleaved.cxx File Reference
#include <gtest/gtest.h>
#include <is_interleaved.hxx>
Include dependency graph for TestIsInterleaved.cxx:

Go to the source code of this file.

Functions

 TEST (TestIsInterleaved, Interleaved)
 

Function Documentation

TEST ( TestIsInterleaved  ,
Interleaved   
)

Definition at line 42 of file TestIsInterleaved.cxx.

43 {
44  // Null interleave on empty sequences - empty interleave expected
45  {
46  Container empty = Container();
47  EXPECT_TRUE(IsInterleaved<IT>
48  (empty.begin(), empty.end(), empty.begin(), empty.end(), empty.begin(), empty.end()));
49  }
50 
51  // interleave with one empty sequence (first) - same sequence expected as interleave
52  {
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()));
56  }
57 
58  // interleave with one empty sequence (second) - same sequence expected as interleave
59  {
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()));
63  }
64 
65  // interleave with same sequence - same sequence cannot be interleave of both
66  {
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()));
70  }
71 
72  // Normal run with interleave
73  {
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()));
79  }
80 
81  // Normal run with interleave on strings
82  {
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()));
88  }
89 
90  // Run with extra letter on FullStr
91  {
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()));
97  }
98 }