summaryrefslogtreecommitdiff
path: root/unittests/Support/ConstantRangeTest.cpp
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-06-28 16:10:13 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-06-28 16:10:13 +0000
commit62d7afad8faf7a1fbbf3402f8e23ce4ece9ab108 (patch)
treed302bbdc65dd8eef01f8d303ac87c9db93d82da1 /unittests/Support/ConstantRangeTest.cpp
parentceb5bc7df1a3f6b1d4a301adf30f4d0e21bbaa15 (diff)
downloadllvm-62d7afad8faf7a1fbbf3402f8e23ce4ece9ab108.tar.gz
llvm-62d7afad8faf7a1fbbf3402f8e23ce4ece9ab108.tar.bz2
llvm-62d7afad8faf7a1fbbf3402f8e23ce4ece9ab108.tar.xz
add ConstantRange::difference (to perform set difference/relative complement)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159352 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Support/ConstantRangeTest.cpp')
-rw-r--r--unittests/Support/ConstantRangeTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/unittests/Support/ConstantRangeTest.cpp b/unittests/Support/ConstantRangeTest.cpp
index a562080981..72540c6999 100644
--- a/unittests/Support/ConstantRangeTest.cpp
+++ b/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);