summaryrefslogtreecommitdiff
path: root/unittests/ADT/APSIntTest.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2015-07-05 14:21:36 +0000
committerDimitry Andric <dim@FreeBSD.org>2015-07-05 14:21:36 +0000
commit1a82d4c088707c791c792f6822f611b47a12bdfe (patch)
tree7c411f9b5d807f7f204fdd16965d8925a82b6d18 /unittests/ADT/APSIntTest.cpp
parent3a0822f094b578157263e04114075ad7df81db41 (diff)
Notes
Diffstat (limited to 'unittests/ADT/APSIntTest.cpp')
-rw-r--r--unittests/ADT/APSIntTest.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/unittests/ADT/APSIntTest.cpp b/unittests/ADT/APSIntTest.cpp
index 5e4e87440bdb..a9b3071d1388 100644
--- a/unittests/ADT/APSIntTest.cpp
+++ b/unittests/ADT/APSIntTest.cpp
@@ -143,4 +143,21 @@ TEST(APSIntTest, compareValues) {
EXPECT_TRUE(APSInt::compareValues(U(8), S(-7).trunc(32)) > 0);
}
+TEST(APSIntTest, FromString) {
+ EXPECT_EQ(APSInt("1").getExtValue(), 1);
+ EXPECT_EQ(APSInt("-1").getExtValue(), -1);
+ EXPECT_EQ(APSInt("0").getExtValue(), 0);
+ EXPECT_EQ(APSInt("56789").getExtValue(), 56789);
+ EXPECT_EQ(APSInt("-1234").getExtValue(), -1234);
}
+
+#if defined(GTEST_HAS_DEATH_TEST) && !defined(NDEBUG)
+
+TEST(APSIntTest, StringDeath) {
+ EXPECT_DEATH(APSInt(""), "Invalid string length");
+ EXPECT_DEATH(APSInt("1a"), "Invalid character in digit string");
+}
+
+#endif
+
+} // end anonymous namespace