Change APFloatTest from using ASSERTs to EXPECTs

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79216 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Erick Tryzelaar 2009-08-17 00:14:11 +00:00
parent 45d6ac2cc1
commit 33d7dd6dc8

View File

@ -18,89 +18,89 @@ using namespace llvm;
namespace {
TEST(APFloatTest, Zero) {
ASSERT_EQ(0.0f, APFloat(APFloat::IEEEsingle, 0.0f).convertToFloat());
ASSERT_EQ(-0.0f, APFloat(APFloat::IEEEsingle, -0.0f).convertToFloat());
EXPECT_EQ(0.0f, APFloat(APFloat::IEEEsingle, 0.0f).convertToFloat());
EXPECT_EQ(-0.0f, APFloat(APFloat::IEEEsingle, -0.0f).convertToFloat());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, 0.0).convertToDouble());
ASSERT_EQ(-0.0, APFloat(APFloat::IEEEdouble, -0.0).convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, 0.0).convertToDouble());
EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, -0.0).convertToDouble());
}
TEST(APFloatTest, SemanticsDeath) {
ASSERT_DEATH(APFloat(APFloat::IEEEsingle, 0.0f).convertToDouble(), "Float semantics are not IEEEdouble");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, 0.0 ).convertToFloat(), "Float semantics are not IEEEsingle");
EXPECT_DEATH(APFloat(APFloat::IEEEsingle, 0.0f).convertToDouble(), "Float semantics are not IEEEdouble");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, 0.0 ).convertToFloat(), "Float semantics are not IEEEsingle");
}
TEST(APFloatTest, fromString) {
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, ".0").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.0").convertToDouble());
ASSERT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0").convertToDouble());
ASSERT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.").convertToDouble());
ASSERT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.0").convertToDouble());
ASSERT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.0").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0e1234").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0e1234").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "00000.").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0000.00000").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, ".00000").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.e1").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.e+1").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.e-1").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e0").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e-0").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e1234").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e-1234").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, ".0").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.0").convertToDouble());
EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0").convertToDouble());
EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.").convertToDouble());
EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-.0").convertToDouble());
EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0.0").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0e1234").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0e1234").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "00000.").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0000.00000").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, ".00000").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.e1").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.e+1").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0.e-1").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e0").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e-0").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e1234").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "000.0000e-1234").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0p1").convertToDouble());
ASSERT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p1").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x00000.p1").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0000.00000p1").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x.00000p1").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0.p1").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0p1234").convertToDouble());
ASSERT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p1234").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x00000.p1234").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0000.00000p1234").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x.00000p1234").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0.p1234").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0p1").convertToDouble());
EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p1").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x00000.p1").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0000.00000p1").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x.00000p1").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0.p1").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0p1234").convertToDouble());
EXPECT_EQ(-0.0, APFloat(APFloat::IEEEdouble, "-0x0p1234").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x00000.p1234").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0000.00000p1234").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x.00000p1234").convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, "0x0.p1234").convertToDouble());
ASSERT_EQ(0.0, APFloat(APFloat::IEEEdouble, StringRef("0e1\02", 3)).convertToDouble());
EXPECT_EQ(0.0, APFloat(APFloat::IEEEdouble, StringRef("0e1\02", 3)).convertToDouble());
}
TEST(APFloatTest, StringDeath) {
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, ""), "Invalid string length");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "-"), "String is only a minus!");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "0x"), "Invalid string");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "."), "String cannot be just a dot");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "-."), "String cannot be just a dot");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "0x."), "String cannot be just a dot");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "-0x."),"String cannot be just a dot");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "0x0"), "Hex strings require an exponent");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "0e"), "Exponent has no digits");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "0e+"), "Exponent has no digits");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "0e-"), "Exponent has no digits");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, ""), "Invalid string length");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-"), "String is only a minus!");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x"), "Invalid string");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "."), "String cannot be just a dot");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-."), "String cannot be just a dot");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x."), "String cannot be just a dot");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "-0x."),"String cannot be just a dot");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x0"), "Hex strings require an exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0e"), "Exponent has no digits");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0e+"), "Exponent has no digits");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0e-"), "Exponent has no digits");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("\0", 1)), "Invalid character in digit string");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\0", 2)), "Invalid character in digit string");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\02", 3)), "Invalid character in digit string");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\02e1", 5)), "Invalid character in digit string");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e\0", 3)), "Invalid character in exponent");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e1\0", 4)), "Invalid character in exponent");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e1\02", 5)), "Invalid character in exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("\0", 1)), "Invalid character in digit string");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\0", 2)), "Invalid character in digit string");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\02", 3)), "Invalid character in digit string");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1\02e1", 5)), "Invalid character in digit string");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e\0", 3)), "Invalid character in exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e1\0", 4)), "Invalid character in exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("1e1\02", 5)), "Invalid character in exponent");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "1.0f"), "Invalid character in digit string");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "1.0f"), "Invalid character in digit string");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x\0", 3)), "Hex strings require an exponent");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\0", 4)), "Hex strings require an exponent");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\02", 5)), "Hex strings require an exponent");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\02p1", 7)), "Hex strings require an exponent");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p\0", 5)), "Invalid character in exponent");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p1\0", 6)), "Invalid character in exponent");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p1\02", 7)), "Invalid character in exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x\0", 3)), "Hex strings require an exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\0", 4)), "Hex strings require an exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\02", 5)), "Hex strings require an exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1\02p1", 7)), "Hex strings require an exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p\0", 5)), "Invalid character in exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p1\0", 6)), "Invalid character in exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, StringRef("0x1p1\02", 7)), "Invalid character in exponent");
ASSERT_DEATH(APFloat(APFloat::IEEEdouble, "0x1p0f"), "Invalid character in exponent");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble, "0x1p0f"), "Invalid character in exponent");
}
}