[Lldb-commits] [lldb] 594130d - Add unit tests for RangeDataVector::FindEntryIndexesThatContain
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Feb 26 07:47:52 PST 2020
Author: Unnar Freyr Erlendsson
Date: 2020-02-26T16:47:42+01:00
New Revision: 594130db0a56c3c3d889f750c5c971fac6f33594
URL: https://github.com/llvm/llvm-project/commit/594130db0a56c3c3d889f750c5c971fac6f33594
DIFF: https://github.com/llvm/llvm-project/commit/594130db0a56c3c3d889f750c5c971fac6f33594.diff
LOG: Add unit tests for RangeDataVector::FindEntryIndexesThatContain
Summary: This adds unit tests for FindEntryIndexesThatContain, this is done in preparation for changing the logic of the function.
Reviewers: labath, teemperor
Reviewed By: labath
Subscribers: arphaman, JDevlieghere, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D75180
Added:
Modified:
lldb/unittests/Utility/RangeMapTest.cpp
Removed:
################################################################################
diff --git a/lldb/unittests/Utility/RangeMapTest.cpp b/lldb/unittests/Utility/RangeMapTest.cpp
index fcefa4797ab7..8a243b656218 100644
--- a/lldb/unittests/Utility/RangeMapTest.cpp
+++ b/lldb/unittests/Utility/RangeMapTest.cpp
@@ -19,6 +19,12 @@ static testing::Matcher<const EntryT *> EntryIs(uint32_t ID) {
return testing::Pointee(testing::Field(&EntryT::data, ID));
}
+std::vector<uint32_t> FindEntryIndexes(uint32_t address, RangeDataVectorT map) {
+ std::vector<uint32_t> result;
+ map.FindEntryIndexesThatContain(address, result);
+ return result;
+}
+
TEST(RangeDataVector, FindEntryThatContains) {
RangeDataVectorT Map;
uint32_t NextID = 0;
@@ -94,3 +100,37 @@ TEST(RangeDataVector, CustomSort) {
EXPECT_THAT(MapC.GetEntryRef(2).data, 51);
EXPECT_THAT(MapC.GetEntryRef(3).data, 50);
}
+
+TEST(RangeDataVector, FindEntryIndexesThatContain) {
+ RangeDataVectorT Map;
+ Map.Append(EntryT(0, 10, 10));
+ Map.Append(EntryT(10, 10, 11));
+ Map.Append(EntryT(20, 10, 12));
+ Map.Sort();
+
+ EXPECT_THAT(FindEntryIndexes(0, Map), testing::ElementsAre(10));
+ EXPECT_THAT(FindEntryIndexes(9, Map), testing::ElementsAre(10));
+ EXPECT_THAT(FindEntryIndexes(10, Map), testing::ElementsAre(11));
+ EXPECT_THAT(FindEntryIndexes(19, Map), testing::ElementsAre(11));
+ EXPECT_THAT(FindEntryIndexes(20, Map), testing::ElementsAre(12));
+ EXPECT_THAT(FindEntryIndexes(29, Map), testing::ElementsAre(12));
+ EXPECT_THAT(FindEntryIndexes(30, Map), testing::ElementsAre());
+}
+
+TEST(RangeDataVector, FindEntryIndexesThatContain_Overlap) {
+ RangeDataVectorT Map;
+ Map.Append(EntryT(0, 40, 10));
+ Map.Append(EntryT(10, 20, 11));
+ Map.Append(EntryT(20, 10, 12));
+ Map.Sort();
+
+ EXPECT_THAT(FindEntryIndexes(0, Map), testing::ElementsAre(10));
+ EXPECT_THAT(FindEntryIndexes(9, Map), testing::ElementsAre(10));
+ EXPECT_THAT(FindEntryIndexes(10, Map), testing::ElementsAre(10, 11));
+ EXPECT_THAT(FindEntryIndexes(19, Map), testing::ElementsAre(10, 11));
+ EXPECT_THAT(FindEntryIndexes(20, Map), testing::ElementsAre(10, 11, 12));
+ EXPECT_THAT(FindEntryIndexes(29, Map), testing::ElementsAre(10, 11, 12));
+ EXPECT_THAT(FindEntryIndexes(30, Map), testing::ElementsAre(10));
+ EXPECT_THAT(FindEntryIndexes(39, Map), testing::ElementsAre(10));
+ EXPECT_THAT(FindEntryIndexes(40, Map), testing::ElementsAre());
+}
More information about the lldb-commits
mailing list