summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/APFloatTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/unittests/ADT/APFloatTest.cpp')
-rw-r--r--llvm/unittests/ADT/APFloatTest.cpp252
1 files changed, 130 insertions, 122 deletions
diff --git a/llvm/unittests/ADT/APFloatTest.cpp b/llvm/unittests/ADT/APFloatTest.cpp
index 518b207e23e..927e1fe1367 100644
--- a/llvm/unittests/ADT/APFloatTest.cpp
+++ b/llvm/unittests/ADT/APFloatTest.cpp
@@ -10,8 +10,8 @@
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/Support/Error.h"
#include "llvm/Support/FormatVariadic.h"
-#include "llvm/Support/raw_ostream.h"
#include "gtest/gtest.h"
#include <cmath>
#include <ostream>
@@ -20,9 +20,17 @@
using namespace llvm;
-static double convertToDoubleFromString(const char *Str) {
+static std::string convertToErrorFromString(StringRef Str) {
llvm::APFloat F(0.0);
- F.convertFromString(Str, llvm::APFloat::rmNearestTiesToEven);
+ auto ErrOrStatus =
+ F.convertFromString(Str, llvm::APFloat::rmNearestTiesToEven);
+ EXPECT_TRUE(!ErrOrStatus);
+ return toString(ErrOrStatus.takeError());
+}
+
+static double convertToDoubleFromString(StringRef Str) {
+ llvm::APFloat F(0.0);
+ EXPECT_FALSE(!F.convertFromString(Str, llvm::APFloat::rmNearestTiesToEven));
return F.convertToDouble();
}
@@ -1156,172 +1164,172 @@ TEST(APFloatTest, SemanticsDeath) {
EXPECT_DEATH(APFloat(APFloat::IEEEsingle(), 0).convertToDouble(), "Float semantics are not IEEEdouble");
EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), 0).convertToFloat(), "Float semantics are not IEEEsingle");
}
+#endif
+#endif
-TEST(APFloatTest, StringDecimalDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ""), "Invalid string length");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+"), "String has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-"), "String has no digits");
+TEST(APFloatTest, StringDecimalError) {
+ EXPECT_EQ("Invalid string length", convertToErrorFromString(""));
+ EXPECT_EQ("String has no digits", convertToErrorFromString("+"));
+ EXPECT_EQ("String has no digits", convertToErrorFromString("-"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("\0", 1)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("1\0", 2)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("1" "\0" "2", 3)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("1" "\0" "2e1", 5)), "Invalid character in significand");
- 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" "\0" "2", 5)), "Invalid character in exponent");
+ EXPECT_EQ("Invalid character in significand", convertToErrorFromString(StringRef("\0", 1)));
+ EXPECT_EQ("Invalid character in significand", convertToErrorFromString(StringRef("1\0", 2)));
+ EXPECT_EQ("Invalid character in significand", convertToErrorFromString(StringRef("1" "\0" "2", 3)));
+ EXPECT_EQ("Invalid character in significand", convertToErrorFromString(StringRef("1" "\0" "2e1", 5)));
+ EXPECT_EQ("Invalid character in exponent", convertToErrorFromString(StringRef("1e\0", 3)));
+ EXPECT_EQ("Invalid character in exponent", convertToErrorFromString(StringRef("1e1\0", 4)));
+ EXPECT_EQ("Invalid character in exponent", convertToErrorFromString(StringRef("1e1" "\0" "2", 5)));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1.0f"), "Invalid character in significand");
+ EXPECT_EQ("Invalid character in significand", convertToErrorFromString("1.0f"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ".."), "String contains multiple dots");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "..0"), "String contains multiple dots");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "1.0.0"), "String contains multiple dots");
+ EXPECT_EQ("String contains multiple dots", convertToErrorFromString(".."));
+ EXPECT_EQ("String contains multiple dots", convertToErrorFromString("..0"));
+ EXPECT_EQ("String contains multiple dots", convertToErrorFromString("1.0.0"));
}
-TEST(APFloatTest, StringDecimalSignificandDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "."), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+."), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-."), "Significand has no digits");
+TEST(APFloatTest, StringDecimalSignificandError) {
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( "."));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+."));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-."));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "e"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+e"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-e"), "Significand has no digits");
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( "e"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+e"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-e"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "e1"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+e1"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-e1"), "Significand has no digits");
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( "e1"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+e1"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-e1"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ".e1"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+.e1"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-.e1"), "Significand has no digits");
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( ".e1"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+.e1"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-.e1"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), ".e"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+.e"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-.e"), "Significand has no digits");
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( ".e"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+.e"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-.e"));
}
-TEST(APFloatTest, StringHexadecimalDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x"), "Invalid string");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x"), "Invalid string");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x"), "Invalid string");
+TEST(APFloatTest, StringHexadecimalError) {
+ EXPECT_EQ("Invalid string", convertToErrorFromString( "0x"));
+ EXPECT_EQ("Invalid string", convertToErrorFromString("+0x"));
+ EXPECT_EQ("Invalid string", convertToErrorFromString("-0x"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x0"), "Hex strings require an exponent");
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString( "0x0"));
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString("+0x0"));
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString("-0x0"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x0."), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x0."), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x0."), "Hex strings require an exponent");
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString( "0x0."));
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString("+0x0."));
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString("-0x0."));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.0"), "Hex strings require an exponent");
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString( "0x.0"));
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString("+0x.0"));
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString("-0x.0"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x0.0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x0.0"), "Hex strings require an exponent");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x0.0"), "Hex strings require an exponent");
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString( "0x0.0"));
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString("+0x0.0"));
+ EXPECT_EQ("Hex strings require an exponent", convertToErrorFromString("-0x0.0"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("0x\0", 3)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("0x1\0", 4)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("0x1" "\0" "2", 5)), "Invalid character in significand");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), StringRef("0x1" "\0" "2p1", 7)), "Invalid character in significand");
- 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" "\0" "2", 7)), "Invalid character in exponent");
+ EXPECT_EQ("Invalid character in significand", convertToErrorFromString(StringRef("0x\0", 3)));
+ EXPECT_EQ("Invalid character in significand", convertToErrorFromString(StringRef("0x1\0", 4)));
+ EXPECT_EQ("Invalid character in significand", convertToErrorFromString(StringRef("0x1" "\0" "2", 5)));
+ EXPECT_EQ("Invalid character in significand", convertToErrorFromString(StringRef("0x1" "\0" "2p1", 7)));
+ EXPECT_EQ("Invalid character in exponent", convertToErrorFromString(StringRef("0x1p\0", 5)));
+ EXPECT_EQ("Invalid character in exponent", convertToErrorFromString(StringRef("0x1p1\0", 6)));
+ EXPECT_EQ("Invalid character in exponent", convertToErrorFromString(StringRef("0x1p1" "\0" "2", 7)));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1p0f"), "Invalid character in exponent");
+ EXPECT_EQ("Invalid character in exponent", convertToErrorFromString("0x1p0f"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x..p1"), "String contains multiple dots");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x..0p1"), "String contains multiple dots");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.0.0p1"), "String contains multiple dots");
+ EXPECT_EQ("String contains multiple dots", convertToErrorFromString("0x..p1"));
+ EXPECT_EQ("String contains multiple dots", convertToErrorFromString("0x..0p1"));
+ EXPECT_EQ("String contains multiple dots", convertToErrorFromString("0x1.0.0p1"));
}
-TEST(APFloatTest, StringHexadecimalSignificandDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x."), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x."), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x."), "Significand has no digits");
+TEST(APFloatTest, StringHexadecimalSignificandError) {
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( "0x."));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+0x."));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-0x."));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0xp"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0xp"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0xp"), "Significand has no digits");
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( "0xp"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+0xp"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-0xp"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0xp+"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0xp+"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0xp+"), "Significand has no digits");
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( "0xp+"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+0xp+"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-0xp+"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0xp-"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0xp-"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0xp-"), "Significand has no digits");
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( "0xp-"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+0xp-"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-0xp-"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.p"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.p"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.p"), "Significand has no digits");
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( "0x.p"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+0x.p"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-0x.p"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.p+"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.p+"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.p+"), "Significand has no digits");
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( "0x.p+"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+0x.p+"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-0x.p+"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.p-"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.p-"), "Significand has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.p-"), "Significand has no digits");
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString( "0x.p-"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("+0x.p-"));
+ EXPECT_EQ("Significand has no digits", convertToErrorFromString("-0x.p-"));
}
-TEST(APFloatTest, StringHexadecimalExponentDeath) {
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1p"), "Exponent has no digits");
+TEST(APFloatTest, StringHexadecimalExponentError) {
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x1p"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x1p"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x1p"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1p+"), "Exponent has no digits");
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x1p+"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x1p+"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x1p+"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1p-"), "Exponent has no digits");
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x1p-"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x1p-"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x1p-"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.p"), "Exponent has no digits");
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x1.p"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x1.p"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x1.p"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.p+"), "Exponent has no digits");
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x1.p+"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x1.p+"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x1.p+"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.p-"), "Exponent has no digits");
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x1.p-"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x1.p-"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x1.p-"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.1p"), "Exponent has no digits");
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x.1p"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x.1p"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x.1p"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.1p+"), "Exponent has no digits");
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x.1p+"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x.1p+"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x.1p+"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x.1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x.1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x.1p-"), "Exponent has no digits");
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x.1p-"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x.1p-"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x.1p-"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.1p"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.1p"), "Exponent has no digits");
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x1.1p"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x1.1p"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x1.1p"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.1p+"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.1p+"), "Exponent has no digits");
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x1.1p+"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x1.1p+"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x1.1p+"));
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "0x1.1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "+0x1.1p-"), "Exponent has no digits");
- EXPECT_DEATH(APFloat(APFloat::IEEEdouble(), "-0x1.1p-"), "Exponent has no digits");
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString( "0x1.1p-"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("+0x1.1p-"));
+ EXPECT_EQ("Exponent has no digits", convertToErrorFromString("-0x1.1p-"));
}
-#endif
-#endif
TEST(APFloatTest, exactInverse) {
APFloat inv(0.0f);
OpenPOWER on IntegriCloud