diff options
Diffstat (limited to 'test/gtest/lattices.cpp')
-rw-r--r-- | test/gtest/lattices.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/gtest/lattices.cpp b/test/gtest/lattices.cpp index ed4f48e38..905f03420 100644 --- a/test/gtest/lattices.cpp +++ b/test/gtest/lattices.cpp @@ -478,6 +478,30 @@ TEST(VectorLattice, Meet) { vector, {false, false}, {false, true}, {true, false}, {true, true}); } +TEST(VectorLattice, JoinSingleton) { + using Vec = analysis::Vector<analysis::Bool>; + Vec vector{analysis::Bool{}, 2}; + auto elem = vector.getBottom(); + + EXPECT_FALSE(vector.join(elem, Vec::SingletonElement(0, false))); + EXPECT_EQ(elem, (std::vector{false, false})); + + EXPECT_TRUE(vector.join(elem, Vec::SingletonElement(1, true))); + EXPECT_EQ(elem, (std::vector{false, true})); +} + +TEST(VectorLattice, MeetSingleton) { + using Vec = analysis::Vector<analysis::Bool>; + Vec vector{analysis::Bool{}, 2}; + auto elem = vector.getTop(); + + EXPECT_FALSE(vector.meet(elem, Vec::SingletonElement(1, true))); + EXPECT_EQ(elem, (std::vector{true, true})); + + EXPECT_TRUE(vector.meet(elem, Vec::SingletonElement(0, false))); + EXPECT_EQ(elem, (std::vector{false, true})); +} + TEST(TupleLattice, GetBottom) { analysis::Tuple<analysis::Bool, analysis::UInt32> tuple{analysis::Bool{}, analysis::UInt32{}}; @@ -656,6 +680,25 @@ TEST(SharedLattice, Join) { } } +TEST(SharedLattice, JoinVecSingleton) { + using Vec = analysis::Vector<analysis::Bool>; + analysis::Shared<Vec> shared{analysis::Vector{analysis::Bool{}, 2}}; + + auto elem = shared.getBottom(); + EXPECT_TRUE(shared.join(elem, Vec::SingletonElement(1, true))); + EXPECT_EQ(*elem, (std::vector{false, true})); +} + +TEST(SharedLattice, JoinInvertedVecSingleton) { + using Vec = analysis::Vector<analysis::Bool>; + analysis::Shared<analysis::Inverted<Vec>> shared{ + analysis::Inverted{analysis::Vector{analysis::Bool{}, 2}}}; + + auto elem = shared.getBottom(); + EXPECT_TRUE(shared.join(elem, Vec::SingletonElement(1, false))); + EXPECT_EQ(*elem, (std::vector{true, false})); +} + TEST(StackLattice, GetBottom) { analysis::Stack stack{analysis::Flat<uint32_t>{}}; EXPECT_EQ(stack.getBottom().size(), 0u); |