From 36d9dbb8a1a99952e63e9e899606bf56c2deb3a4 Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Sun, 16 Aug 2009 23:36:01 +0000 Subject: [PATCH] Add failure tests to APInt unit test. llvm-svn: 79209 --- unittests/ADT/APIntTest.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/unittests/ADT/APIntTest.cpp b/unittests/ADT/APIntTest.cpp index 4a6b176a2b4..207c6337b8c 100644 --- a/unittests/ADT/APIntTest.cpp +++ b/unittests/ADT/APIntTest.cpp @@ -172,4 +172,15 @@ TEST(APIntTest, fromString) { EXPECT_EQ(APInt(1, 1), APInt(1, "1", 16)); } +TEST(APIntTest, StringDeath) { + EXPECT_DEATH(APInt(0, "", 0), "bitwidth too small"); + EXPECT_DEATH(APInt(32, "", 0), "Radix should be 2, 8, 10, or 16!"); + EXPECT_DEATH(APInt(32, "", 10), "Invalid string length"); + EXPECT_DEATH(APInt(32, "-", 10), "string is only a minus!"); + EXPECT_DEATH(APInt(1, "1234", 10), "Insufficient bit width"); + EXPECT_DEATH(APInt(32, "\0", 10), "Invalid string length"); + EXPECT_DEATH(APInt(32, StringRef("1\02", 3), 10), "Invalid character in digit string"); + EXPECT_DEATH(APInt(32, "1L", 10), "Invalid character in digit string"); +} + }