mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Get GNU GMP test suite fully passing
- Fix stdio fmemopen() buffer behaviors - Fix scanf() to return EOF when appropriate - Prefer fseek/ftell names over fseeko/ftello - Ensure locale field is always set in the TIB - Fix recent regression in vfprintf() return count - Make %n directive in scanf() have standard behavior
This commit is contained in:
parent
755ae64e73
commit
63a1636e1f
20 changed files with 228 additions and 51 deletions
|
@ -42,7 +42,6 @@ TEST(sscanf, testMultiple) {
|
|||
|
||||
TEST(sscanf, testDecimal) {
|
||||
EXPECT_EQ(123, sscanf1("123", "%d"));
|
||||
EXPECT_EQ(123, sscanf1("123", "%n"));
|
||||
EXPECT_EQ(123, sscanf1("123", "%u"));
|
||||
EXPECT_EQ((uint32_t)-123, sscanf1("-123", "%d"));
|
||||
}
|
||||
|
@ -258,3 +257,30 @@ TEST(sscanf, test0) {
|
|||
ASSERT_EQ(sscanf("0", "%b", &v), 1);
|
||||
ASSERT_EQ(v, 0);
|
||||
}
|
||||
|
||||
TEST(sscanf, n) {
|
||||
int x, y;
|
||||
EXPECT_EQ(1, sscanf("7 2 3 4", "%d%n", &x, &y));
|
||||
EXPECT_EQ(7, x);
|
||||
EXPECT_EQ(1, y);
|
||||
}
|
||||
|
||||
TEST(sscanf, eofForNoMatching) {
|
||||
int y = 666;
|
||||
char x[8] = "hi";
|
||||
EXPECT_EQ(-1, sscanf(" ", "%s%n", &x, &y));
|
||||
EXPECT_STREQ("hi", x);
|
||||
EXPECT_EQ(666, y);
|
||||
}
|
||||
|
||||
TEST(sscanf, eofConditions) {
|
||||
int x = 666;
|
||||
EXPECT_EQ(-1, sscanf("", "%d", &x));
|
||||
EXPECT_EQ(666, x);
|
||||
EXPECT_EQ(-1, sscanf(" ", "%d", &x));
|
||||
EXPECT_EQ(666, x);
|
||||
EXPECT_EQ(-1, sscanf("123", "%*d%d", &x));
|
||||
EXPECT_EQ(666, x);
|
||||
EXPECT_EQ(-1, sscanf("123", "%*d%n", &x));
|
||||
EXPECT_EQ(666, x);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue