Skip to content

Commit 4a8f2ef

Browse files
authored
Merge pull request #6 from bugparty/copilot/sub-pr-2-yet-again
Enhance iterator equality test coverage
2 parents 235c9ce + 55aec70 commit 4a8f2ef

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

test_main.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,26 @@ TEST(RingBufferTest, IteratorsFromDifferentBuffersAreNotEqual) {
119119
ring_buffer<int, 3> b1;
120120
ring_buffer<int, 3> b2;
121121

122+
// Iterators from different buffers should not be equal
122123
EXPECT_NE(b1.cbegin(), b2.cbegin());
124+
125+
// Add elements to both buffers
126+
b1.push_back(1);
127+
b1.push_back(2);
128+
b2.push_back(1);
129+
b2.push_back(2);
130+
131+
// Iterators at the same logical position from different buffers should still be unequal
132+
EXPECT_NE(b1.cbegin(), b2.cbegin());
133+
EXPECT_NE(b1.cend(), b2.cend());
134+
135+
// Iterators from the same buffer at the same position should be equal
136+
EXPECT_EQ(b1.cbegin(), b1.cbegin());
137+
EXPECT_EQ(b1.cend(), b1.cend());
138+
139+
// begin() and end() from the same buffer should be different when not empty
140+
EXPECT_NE(b1.cbegin(), b1.cend());
141+
EXPECT_NE(b2.cbegin(), b2.cend());
123142
}
124143

125144
TEST(RingBufferTest, NoOverwriteWhenFull) {

0 commit comments

Comments
 (0)