summaryrefslogtreecommitdiff
path: root/absl/container/internal/test_instance_tracker_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'absl/container/internal/test_instance_tracker_test.cc')
-rw-r--r--absl/container/internal/test_instance_tracker_test.cc22
1 files changed, 22 insertions, 0 deletions
diff --git a/absl/container/internal/test_instance_tracker_test.cc b/absl/container/internal/test_instance_tracker_test.cc
index 9efb6771..0ae57636 100644
--- a/absl/container/internal/test_instance_tracker_test.cc
+++ b/absl/container/internal/test_instance_tracker_test.cc
@@ -157,4 +157,26 @@ TEST(TestInstanceTracker, ExistingInstances) {
EXPECT_EQ(1, tracker.moves());
}
+TEST(TestInstanceTracker, Comparisons) {
+ InstanceTracker tracker;
+ MovableOnlyInstance one(1), two(2);
+
+ EXPECT_EQ(0, tracker.comparisons());
+ EXPECT_FALSE(one == two);
+ EXPECT_EQ(1, tracker.comparisons());
+ EXPECT_TRUE(one != two);
+ EXPECT_EQ(2, tracker.comparisons());
+ EXPECT_TRUE(one < two);
+ EXPECT_EQ(3, tracker.comparisons());
+ EXPECT_FALSE(one > two);
+ EXPECT_EQ(4, tracker.comparisons());
+ EXPECT_TRUE(one <= two);
+ EXPECT_EQ(5, tracker.comparisons());
+ EXPECT_FALSE(one >= two);
+ EXPECT_EQ(6, tracker.comparisons());
+
+ tracker.ResetCopiesMovesSwaps();
+ EXPECT_EQ(0, tracker.comparisons());
+}
+
} // namespace