Make small fixes and oops ran clang-format on dtoa

This commit is contained in:
Justine Tunney 2020-06-30 19:55:47 -07:00
parent b5b60015f5
commit ac00be1a4e
47 changed files with 4933 additions and 5306 deletions

View file

@ -23,10 +23,18 @@
/* todo(jart): work on this more */
TEST(strtoimax, testZero) { EXPECT_EQ(0, strtoimax("0", NULL, 0)); }
TEST(strtoimax, testDecimal) { EXPECT_EQ(-123, strtoimax("-123", NULL, 0)); }
TEST(strtoimax, testHex) { EXPECT_EQ(-255, strtoimax("-0xff", NULL, 0)); }
TEST(strtoimax, testOctal) { EXPECT_EQ(-123, strtoimax("-0173", NULL, 0)); }
TEST(strtoimax, testZero) {
EXPECT_EQ(0, strtoimax("0", NULL, 0));
}
TEST(strtoimax, testDecimal) {
EXPECT_EQ(-123, strtoimax("-123", NULL, 0));
}
TEST(strtoimax, testHex) {
EXPECT_EQ(-255, strtoimax("-0xff", NULL, 0));
}
TEST(strtoimax, testOctal) {
EXPECT_EQ(-123, strtoimax("-0173", NULL, 0));
}
TEST(strtoimax, testLimits) {
EXPECT_EQ(
@ -36,3 +44,9 @@ TEST(strtoimax, testLimits) {
((uintmax_t)0x7fffffffffffffff) << 64 | (uintmax_t)0xffffffffffffffff,
strtoimax("0x7fffffffffffffffffffffffffffffff", NULL, 0));
}
TEST(strtoimax, testZeroExtend) {
EXPECT_EQ(-1, strtoimax("-1", NULL, 0));
EXPECT_EQ(0xffffffff, strtoimax("-1u", NULL, 0));
EXPECT_EQ(0xffffffffffffffff, strtoimax("-1ul", NULL, 0));
}

View file

@ -434,7 +434,7 @@ TEST(sprintf, test_float) {
EXPECT_STREQ("a0.5 ", Format("a%-5.1f", 0.5));
EXPECT_STREQ("a0.5 end", Format("a%-5.1fend", 0.5));
/* out of range in the moment, need to be fixed by someone */
EXPECT_STREQ("INFINITY", Format("%.1f", 1E20));
EXPECT_STREQ("inf", Format("%.1f", 1E20));
}
TEST(sprintf, test_types) {

View file

@ -33,10 +33,10 @@ TEST(round, test) {
TEST(round, testCornerCases) {
EXPECT_STREQ("-0", gc(xdtoa(round(-0.0))));
EXPECT_STREQ("NAN", gc(xdtoa(round(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoa(round(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoa(round(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoa(round(-INFINITY))));
EXPECT_STREQ("nan", gc(xdtoa(round(NAN))));
EXPECT_STREQ("-nan", gc(xdtoa(round(-NAN))));
EXPECT_STREQ("inf", gc(xdtoa(round(INFINITY))));
EXPECT_STREQ("-inf", gc(xdtoa(round(-INFINITY))));
}
TEST(lround, test) {
@ -60,10 +60,10 @@ TEST(roundf, test) {
TEST(roundf, testCornerCases) {
EXPECT_STREQ("-0", gc(xdtoa(roundf(-0.0))));
EXPECT_STREQ("NAN", gc(xdtoa(roundf(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoa(roundf(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoa(roundf(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoa(roundf(-INFINITY))));
EXPECT_STREQ("nan", gc(xdtoa(roundf(NAN))));
EXPECT_STREQ("-nan", gc(xdtoa(roundf(-NAN))));
EXPECT_STREQ("inf", gc(xdtoa(roundf(INFINITY))));
EXPECT_STREQ("-inf", gc(xdtoa(roundf(-INFINITY))));
}
TEST(lroundf, test) {

View file

@ -38,10 +38,10 @@ TEST(round, test) {
TEST(round, testCornerCases) {
EXPECT_STREQ("-0", gc(xdtoa(tinymath_round(-0.0))));
EXPECT_STREQ("NAN", gc(xdtoa(tinymath_round(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoa(tinymath_round(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoa(tinymath_round(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoa(tinymath_round(-INFINITY))));
EXPECT_STREQ("nan", gc(xdtoa(tinymath_round(NAN))));
EXPECT_STREQ("-nan", gc(xdtoa(tinymath_round(-NAN))));
EXPECT_STREQ("inf", gc(xdtoa(tinymath_round(INFINITY))));
EXPECT_STREQ("-inf", gc(xdtoa(tinymath_round(-INFINITY))));
}
TEST(lround, test) {
@ -65,10 +65,10 @@ TEST(roundf, test) {
TEST(roundf, testCornerCases) {
EXPECT_STREQ("-0", gc(xdtoa(tinymath_roundf(-0.0))));
EXPECT_STREQ("NAN", gc(xdtoa(tinymath_roundf(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoa(tinymath_roundf(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoa(tinymath_roundf(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoa(tinymath_roundf(-INFINITY))));
EXPECT_STREQ("nan", gc(xdtoa(tinymath_roundf(NAN))));
EXPECT_STREQ("-nan", gc(xdtoa(tinymath_roundf(-NAN))));
EXPECT_STREQ("inf", gc(xdtoa(tinymath_roundf(INFINITY))));
EXPECT_STREQ("-inf", gc(xdtoa(tinymath_roundf(-INFINITY))));
}
TEST(lroundf, test) {
@ -103,18 +103,18 @@ TEST(roundf$k8, test) {
TEST(round$k8, testCornerCases) {
EXPECT_STREQ("-0", gc(xdtoa(tinymath_round$k8(-0.0))));
EXPECT_STREQ("NAN", gc(xdtoa(tinymath_round$k8(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoa(tinymath_round$k8(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoa(tinymath_round$k8(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoa(tinymath_round$k8(-INFINITY))));
EXPECT_STREQ("nan", gc(xdtoa(tinymath_round$k8(NAN))));
EXPECT_STREQ("-nan", gc(xdtoa(tinymath_round$k8(-NAN))));
EXPECT_STREQ("inf", gc(xdtoa(tinymath_round$k8(INFINITY))));
EXPECT_STREQ("-inf", gc(xdtoa(tinymath_round$k8(-INFINITY))));
}
TEST(roundf$k8, testCornerCases) {
EXPECT_STREQ("-0", gc(xdtoa(tinymath_roundf$k8(-0.0))));
EXPECT_STREQ("NAN", gc(xdtoa(tinymath_roundf$k8(NAN))));
EXPECT_STREQ("-NAN", gc(xdtoa(tinymath_roundf$k8(-NAN))));
EXPECT_STREQ("INFINITY", gc(xdtoa(tinymath_roundf$k8(INFINITY))));
EXPECT_STREQ("-INFINITY", gc(xdtoa(tinymath_roundf$k8(-INFINITY))));
EXPECT_STREQ("nan", gc(xdtoa(tinymath_roundf$k8(NAN))));
EXPECT_STREQ("-nan", gc(xdtoa(tinymath_roundf$k8(-NAN))));
EXPECT_STREQ("inf", gc(xdtoa(tinymath_roundf$k8(INFINITY))));
EXPECT_STREQ("-inf", gc(xdtoa(tinymath_roundf$k8(-INFINITY))));
}
#endif

View file

@ -83,3 +83,8 @@ TEST(strwidth, tab) {
TEST(wcwidth, block) {
EXPECT_EQ(1, wcwidth(u''));
}
TEST(strwidth, testTextDelimitingControlCodes_dontHaveSubstance) {
EXPECT_EQ(0, strwidth("\0"));
EXPECT_EQ(0, strwidth("\1"));
}