diff options
| author | Nuno Lopes <nunoplopes@sapo.pt> | 2012-06-28 16:10:13 +0000 |
|---|---|---|
| committer | Nuno Lopes <nunoplopes@sapo.pt> | 2012-06-28 16:10:13 +0000 |
| commit | 5020db2a8c40b7046ef62970690415361fe45907 (patch) | |
| tree | 6ecedf8271533dd84c8d7c4342272e361ed95926 /llvm/unittests/Support/ConstantRangeTest.cpp | |
| parent | debc71cea3ae0e2b40fbe511de2d4f0e56a66fb1 (diff) | |
| download | llvm-5020db2a8c40b7046ef62970690415361fe45907.zip llvm-5020db2a8c40b7046ef62970690415361fe45907.tar.gz llvm-5020db2a8c40b7046ef62970690415361fe45907.tar.bz2 | |
add ConstantRange::difference (to perform set difference/relative complement)
llvm-svn: 159352
Diffstat (limited to 'llvm/unittests/Support/ConstantRangeTest.cpp')
| -rw-r--r-- | llvm/unittests/Support/ConstantRangeTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/unittests/Support/ConstantRangeTest.cpp b/llvm/unittests/Support/ConstantRangeTest.cpp index a562080..72540c6 100644 --- a/llvm/unittests/Support/ConstantRangeTest.cpp +++ b/llvm/unittests/Support/ConstantRangeTest.cpp @@ -289,6 +289,23 @@ TEST_F(ConstantRangeTest, UnionWith) { ConstantRange(16)); } +TEST_F(ConstantRangeTest, SetDifference) { + EXPECT_EQ(Full.difference(Empty), Full); + EXPECT_EQ(Full.difference(Full), Empty); + EXPECT_EQ(Empty.difference(Empty), Empty); + EXPECT_EQ(Empty.difference(Full), Empty); + + ConstantRange A(APInt(16, 3), APInt(16, 7)); + ConstantRange B(APInt(16, 5), APInt(16, 9)); + ConstantRange C(APInt(16, 3), APInt(16, 5)); + ConstantRange D(APInt(16, 7), APInt(16, 9)); + ConstantRange E(APInt(16, 5), APInt(16, 4)); + ConstantRange F(APInt(16, 7), APInt(16, 3)); + EXPECT_EQ(A.difference(B), C); + EXPECT_EQ(B.difference(A), D); + EXPECT_EQ(E.difference(A), F); +} + TEST_F(ConstantRangeTest, SubtractAPInt) { EXPECT_EQ(Full.subtract(APInt(16, 4)), Full); EXPECT_EQ(Empty.subtract(APInt(16, 4)), Empty); |
