aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-17 22:07:54 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2010-12-17 22:07:54 +0000
commitd715e07efe29451afe2849abd4bd362d0f75a004 (patch)
tree8c26a70c18ca59cad2a60df11826da32ae5bcd18 /unittests
parent5049ee5b11fe55e5a553b5388406aab874717672 (diff)
Add more checks to IntervalMapOverlaps::advance() to ensure that advanceTo sees
monotonic keys. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ADT/IntervalMapTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/unittests/ADT/IntervalMapTest.cpp b/unittests/ADT/IntervalMapTest.cpp
index fad7318387..b5556d265a 100644
--- a/unittests/ADT/IntervalMapTest.cpp
+++ b/unittests/ADT/IntervalMapTest.cpp
@@ -659,6 +659,19 @@ TEST(IntervalMapOverlapsTest, BigMaps) {
++AB;
EXPECT_FALSE(AB.valid());
+ // Test advanceTo.
+ UUOverlaps AB2(mapA, mapB);
+ AB2.advanceTo(410);
+ ASSERT_TRUE(AB2.valid());
+ EXPECT_EQ(410u, AB2.a().start());
+ EXPECT_EQ(402u, AB2.b().start());
+
+ // It is valid to advanceTo with any monotonic sequence.
+ AB2.advanceTo(411);
+ ASSERT_TRUE(AB2.valid());
+ EXPECT_EQ(410u, AB2.a().start());
+ EXPECT_EQ(402u, AB2.b().start());
+
// Check reversed maps.
UUOverlaps BA(mapB, mapA);
ASSERT_TRUE(BA.valid());
@@ -686,6 +699,18 @@ TEST(IntervalMapOverlapsTest, BigMaps) {
EXPECT_EQ(600u, BA.a().start());
++BA;
EXPECT_FALSE(BA.valid());
+
+ // Test advanceTo.
+ UUOverlaps BA2(mapB, mapA);
+ BA2.advanceTo(410);
+ ASSERT_TRUE(BA2.valid());
+ EXPECT_EQ(410u, BA2.b().start());
+ EXPECT_EQ(402u, BA2.a().start());
+
+ BA2.advanceTo(411);
+ ASSERT_TRUE(BA2.valid());
+ EXPECT_EQ(410u, BA2.b().start());
+ EXPECT_EQ(402u, BA2.a().start());
}
} // namespace