Lines Matching refs:buf
286 char buf[32]; in TEST() local
287 snprintf(buf, sizeof(buf), "%zd", v); in TEST()
292 char buf[BUFSIZ]; in TEST() local
293 EXPECT_EQ(23, snprintf(buf, sizeof(buf), "<%a>", 9990.235)); in TEST()
294 EXPECT_STREQ("<0x1.3831e147ae148p+13>", buf); in TEST()
300 char buf[BUFSIZ]; in TEST() local
308 EXPECT_EQ(41, snprintf(buf, sizeof(buf), "<%La>", u.v)); in TEST()
309 EXPECT_STREQ("<-0x1.dfdfdfdfdfdf9b9b9b9b9b9b9b9bp+8160>", buf); in TEST()
313 EXPECT_EQ(41, snprintf(buf, sizeof(buf), "<%La>", u.v)); in TEST()
314 EXPECT_STREQ("<0x1.ffffffffffffffffffffffffffffp+16383>", buf); in TEST()
318 EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%La>", u.v)); in TEST()
319 EXPECT_STREQ("<0x0p+0>", buf); in TEST()
326 char buf[BUFSIZ]; in TEST() local
328 EXPECT_EQ(3, snprintf(buf, sizeof(buf), "<%lc>", wc)); in TEST()
329 EXPECT_STREQ("<a>", buf); in TEST()
333 char buf[BUFSIZ]; in TEST() local
335 EXPECT_EQ(3, snprintf(buf, sizeof(buf), "<%C>", wc)); in TEST()
336 EXPECT_STREQ("<a>", buf); in TEST()
340 char buf[BUFSIZ]; in TEST() local
342 EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%ls>", ws)); in TEST()
343 EXPECT_STREQ("<(null)>", buf); in TEST()
347 EXPECT_EQ(4, snprintf(buf, sizeof(buf), "<%ls>", ws)); in TEST()
348 EXPECT_STREQ("<hi>", buf); in TEST()
352 char buf[BUFSIZ]; in TEST() local
354 EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%S>", ws)); in TEST()
355 EXPECT_STREQ("<(null)>", buf); in TEST()
359 EXPECT_EQ(4, snprintf(buf, sizeof(buf), "<%S>", ws)); in TEST()
360 EXPECT_STREQ("<hi>", buf); in TEST()
366 char buf[32]; in TEST() local
368 EXPECT_DEATH(snprintf(buf, sizeof(buf), "a %n b", &i), "%n not allowed on Android"); in TEST()
375 char buf[BUFSIZ]; in TEST() local
377 snprintf(buf, sizeof(buf), "a"); in TEST()
378 EXPECT_STREQ("a", buf); in TEST()
380 snprintf(buf, sizeof(buf), "%%"); in TEST()
381 EXPECT_STREQ("%", buf); in TEST()
383 snprintf(buf, sizeof(buf), "01234"); in TEST()
384 EXPECT_STREQ("01234", buf); in TEST()
386 snprintf(buf, sizeof(buf), "a%sb", "01234"); in TEST()
387 EXPECT_STREQ("a01234b", buf); in TEST()
390 snprintf(buf, sizeof(buf), "a%sb", s); in TEST()
391 EXPECT_STREQ("a(null)b", buf); in TEST()
393 snprintf(buf, sizeof(buf), "aa%scc", "bb"); in TEST()
394 EXPECT_STREQ("aabbcc", buf); in TEST()
396 snprintf(buf, sizeof(buf), "a%cc", 'b'); in TEST()
397 EXPECT_STREQ("abc", buf); in TEST()
399 snprintf(buf, sizeof(buf), "a%db", 1234); in TEST()
400 EXPECT_STREQ("a1234b", buf); in TEST()
402 snprintf(buf, sizeof(buf), "a%db", -8123); in TEST()
403 EXPECT_STREQ("a-8123b", buf); in TEST()
405 snprintf(buf, sizeof(buf), "a%hdb", static_cast<short>(0x7fff0010)); in TEST()
406 EXPECT_STREQ("a16b", buf); in TEST()
408 snprintf(buf, sizeof(buf), "a%hhdb", static_cast<char>(0x7fffff10)); in TEST()
409 EXPECT_STREQ("a16b", buf); in TEST()
411 snprintf(buf, sizeof(buf), "a%lldb", 0x1000000000LL); in TEST()
412 EXPECT_STREQ("a68719476736b", buf); in TEST()
414 snprintf(buf, sizeof(buf), "a%ldb", 70000L); in TEST()
415 EXPECT_STREQ("a70000b", buf); in TEST()
417 snprintf(buf, sizeof(buf), "a%pb", reinterpret_cast<void*>(0xb0001234)); in TEST()
418 EXPECT_STREQ("a0xb0001234b", buf); in TEST()
420 snprintf(buf, sizeof(buf), "a%xz", 0x12ab); in TEST()
421 EXPECT_STREQ("a12abz", buf); in TEST()
423 snprintf(buf, sizeof(buf), "a%Xz", 0x12ab); in TEST()
424 EXPECT_STREQ("a12ABz", buf); in TEST()
426 snprintf(buf, sizeof(buf), "a%08xz", 0x123456); in TEST()
427 EXPECT_STREQ("a00123456z", buf); in TEST()
429 snprintf(buf, sizeof(buf), "a%5dz", 1234); in TEST()
430 EXPECT_STREQ("a 1234z", buf); in TEST()
432 snprintf(buf, sizeof(buf), "a%05dz", 1234); in TEST()
433 EXPECT_STREQ("a01234z", buf); in TEST()
435 snprintf(buf, sizeof(buf), "a%8dz", 1234); in TEST()
436 EXPECT_STREQ("a 1234z", buf); in TEST()
438 snprintf(buf, sizeof(buf), "a%-8dz", 1234); in TEST()
439 EXPECT_STREQ("a1234 z", buf); in TEST()
441 snprintf(buf, sizeof(buf), "A%-11sZ", "abcdef"); in TEST()
442 EXPECT_STREQ("Aabcdef Z", buf); in TEST()
444 snprintf(buf, sizeof(buf), "A%s:%dZ", "hello", 1234); in TEST()
445 EXPECT_STREQ("Ahello:1234Z", buf); in TEST()
447 snprintf(buf, sizeof(buf), "a%03d:%d:%02dz", 5, 5, 5); in TEST()
448 EXPECT_STREQ("a005:5:05z", buf); in TEST()
451 snprintf(buf, sizeof(buf), "a%d,%pz", 5, p); in TEST()
453 EXPECT_STREQ("a5,0x0z", buf); in TEST()
455 EXPECT_STREQ("a5,(nil)z", buf); in TEST()
458 snprintf(buf, sizeof(buf), "a%lld,%d,%d,%dz", 0x1000000000LL, 6, 7, 8); in TEST()
459 EXPECT_STREQ("a68719476736,6,7,8z", buf); in TEST()
461 snprintf(buf, sizeof(buf), "a_%f_b", 1.23f); in TEST()
462 EXPECT_STREQ("a_1.230000_b", buf); in TEST()
464 snprintf(buf, sizeof(buf), "a_%g_b", 3.14); in TEST()
465 EXPECT_STREQ("a_3.14_b", buf); in TEST()
467 snprintf(buf, sizeof(buf), "%1$s %1$s", "print_me_twice"); in TEST()
468 EXPECT_STREQ("print_me_twice print_me_twice", buf); in TEST()
477 T buf[BUFSIZ]; in CheckInfNan() local
482 snprintf_fn(buf, sizeof(buf), fmt, nanf("")); in CheckInfNan()
483 EXPECT_STREQ(nan_, buf) << fmt; in CheckInfNan()
484 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
487 snprintf_fn(buf, sizeof(buf), fmt, -nanf("")); in CheckInfNan()
488 EXPECT_STREQ(minus_nan, buf) << fmt; in CheckInfNan()
489 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
492 snprintf_fn(buf, sizeof(buf), fmt_plus, nanf("")); in CheckInfNan()
493 EXPECT_STREQ(plus_nan, buf) << fmt_plus; in CheckInfNan()
494 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
497 snprintf_fn(buf, sizeof(buf), fmt_plus, -nanf("")); in CheckInfNan()
498 EXPECT_STREQ(minus_nan, buf) << fmt_plus; in CheckInfNan()
499 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
504 snprintf_fn(buf, sizeof(buf), fmt, HUGE_VALF); in CheckInfNan()
505 EXPECT_STREQ(inf_, buf) << fmt; in CheckInfNan()
506 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
509 snprintf_fn(buf, sizeof(buf), fmt, -HUGE_VALF); in CheckInfNan()
510 EXPECT_STREQ(minus_inf, buf) << fmt; in CheckInfNan()
511 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
514 snprintf_fn(buf, sizeof(buf), fmt_plus, HUGE_VALF); in CheckInfNan()
515 EXPECT_STREQ(plus_inf, buf) << fmt_plus; in CheckInfNan()
516 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
519 snprintf_fn(buf, sizeof(buf), fmt_plus, -HUGE_VALF); in CheckInfNan()
520 EXPECT_STREQ(minus_inf, buf) << fmt_plus; in CheckInfNan()
521 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
525 snprintf_fn(buf, sizeof(buf), fmt_string, "[InFiNiTy]"); in CheckInfNan()
526 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)) << buf; in CheckInfNan()
528 snprintf_fn(buf, sizeof(buf), fmt_string, "[NaN]"); in CheckInfNan()
529 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)) << buf; in CheckInfNan()
605 wchar_t buf[nchars]; in TEST() local
607 ASSERT_EQ(2, swprintf(buf, nchars, L"ab")) << strerror(errno); in TEST()
608 ASSERT_EQ(std::wstring(L"ab"), buf); in TEST()
609 ASSERT_EQ(5, swprintf(buf, nchars, L"%s", "abcde")); in TEST()
610 ASSERT_EQ(std::wstring(L"abcde"), buf); in TEST()
614 ASSERT_EQ(-1, swprintf(buf, 4, L"%s", "abcde")); in TEST()
617 ASSERT_EQ(12, swprintf(buf, nchars, L"%s", kString)); in TEST()
618 ASSERT_EQ(std::wstring(L"Hello, World"), buf); in TEST()
619 ASSERT_EQ(12, swprintf(buf, 13, L"%s", kString)); in TEST()
620 ASSERT_EQ(std::wstring(L"Hello, World"), buf); in TEST()
625 wchar_t buf[nchars]; in TEST() local
627 ASSERT_EQ(20, swprintf(buf, nchars, L"%a", 3.1415926535)); in TEST()
628 ASSERT_EQ(std::wstring(L"0x1.921fb54411744p+1"), buf); in TEST()
633 wchar_t buf[nchars]; in TEST() local
636 EXPECT_EQ(3, swprintf(buf, nchars, L"<%lc>", wc)); in TEST()
637 EXPECT_EQ(std::wstring(L"<a>"), buf); in TEST()
642 wchar_t buf[nchars]; in TEST() local
645 EXPECT_EQ(3, swprintf(buf, nchars, L"<%C>", wc)); in TEST()
646 EXPECT_EQ(std::wstring(L"<a>"), buf); in TEST()
651 wchar_t buf[nchars]; in TEST() local
653 swprintf(buf, nchars, L"%jd", INTMAX_MAX); in TEST()
654 EXPECT_EQ(std::wstring(L"9223372036854775807"), buf); in TEST()
659 wchar_t buf[nchars]; in TEST() local
661 swprintf(buf, nchars, L"%jd", INTMAX_MIN); in TEST()
662 EXPECT_EQ(std::wstring(L"-9223372036854775808"), buf); in TEST()
667 wchar_t buf[nchars]; in TEST() local
669 swprintf(buf, nchars, L"%ju", UINTMAX_MAX); in TEST()
670 EXPECT_EQ(std::wstring(L"18446744073709551615"), buf); in TEST()
675 wchar_t buf[nchars]; in TEST() local
677 swprintf(buf, nchars, L"%1$ju", UINTMAX_MAX); in TEST()
678 EXPECT_EQ(std::wstring(L"18446744073709551615"), buf); in TEST()
683 wchar_t buf[nchars]; in TEST() local
686 ASSERT_EQ(12, swprintf(buf, nchars, L"%ls", kWideString)); in TEST()
687 ASSERT_EQ(std::wstring(kWideString), buf); in TEST()
688 ASSERT_EQ(12, swprintf(buf, 13, L"%ls", kWideString)); in TEST()
689 ASSERT_EQ(std::wstring(kWideString), buf); in TEST()
694 wchar_t buf[nchars]; in TEST() local
697 ASSERT_EQ(12, swprintf(buf, nchars, L"%S", kWideString)); in TEST()
698 ASSERT_EQ(std::wstring(kWideString), buf); in TEST()
699 ASSERT_EQ(12, swprintf(buf, 13, L"%S", kWideString)); in TEST()
700 ASSERT_EQ(std::wstring(kWideString), buf); in TEST()
704 char buf[BUFSIZ]; in TEST() local
705 snprintf(buf, sizeof(buf), "%d", INT_MAX); in TEST()
706 EXPECT_STREQ("2147483647", buf); in TEST()
710 char buf[BUFSIZ]; in TEST() local
711 snprintf(buf, sizeof(buf), "%d", INT_MIN); in TEST()
712 EXPECT_STREQ("-2147483648", buf); in TEST()
716 char buf[BUFSIZ]; in TEST() local
717 snprintf(buf, sizeof(buf), "%jd", INTMAX_MAX); in TEST()
718 EXPECT_STREQ("9223372036854775807", buf); in TEST()
722 char buf[BUFSIZ]; in TEST() local
723 snprintf(buf, sizeof(buf), "%jd", INTMAX_MIN); in TEST()
724 EXPECT_STREQ("-9223372036854775808", buf); in TEST()
728 char buf[BUFSIZ]; in TEST() local
729 snprintf(buf, sizeof(buf), "%ju", UINTMAX_MAX); in TEST()
730 EXPECT_STREQ("18446744073709551615", buf); in TEST()
734 char buf[BUFSIZ]; in TEST() local
735 snprintf(buf, sizeof(buf), "%1$ju", UINTMAX_MAX); in TEST()
736 EXPECT_STREQ("18446744073709551615", buf); in TEST()
740 char buf[BUFSIZ]; in TEST() local
741 snprintf(buf, sizeof(buf), "%ld", LONG_MAX); in TEST()
743 EXPECT_STREQ("9223372036854775807", buf); in TEST()
745 EXPECT_STREQ("2147483647", buf); in TEST()
750 char buf[BUFSIZ]; in TEST() local
751 snprintf(buf, sizeof(buf), "%ld", LONG_MIN); in TEST()
753 EXPECT_STREQ("-9223372036854775808", buf); in TEST()
755 EXPECT_STREQ("-2147483648", buf); in TEST()
760 char buf[BUFSIZ]; in TEST() local
761 snprintf(buf, sizeof(buf), "%lld", LLONG_MAX); in TEST()
762 EXPECT_STREQ("9223372036854775807", buf); in TEST()
766 char buf[BUFSIZ]; in TEST() local
767 snprintf(buf, sizeof(buf), "%lld", LLONG_MIN); in TEST()
768 EXPECT_STREQ("-9223372036854775808", buf); in TEST()
772 char buf[BUFSIZ]; in TEST() local
773 snprintf(buf, sizeof(buf), "%o", UINT_MAX); in TEST()
774 EXPECT_STREQ("37777777777", buf); in TEST()
778 char buf[BUFSIZ]; in TEST() local
779 snprintf(buf, sizeof(buf), "%u", UINT_MAX); in TEST()
780 EXPECT_STREQ("4294967295", buf); in TEST()
784 char buf[BUFSIZ]; in TEST() local
785 snprintf(buf, sizeof(buf), "%x", UINT_MAX); in TEST()
786 EXPECT_STREQ("ffffffff", buf); in TEST()
790 char buf[BUFSIZ]; in TEST() local
791 snprintf(buf, sizeof(buf), "%X", UINT_MAX); in TEST()
792 EXPECT_STREQ("FFFFFFFF", buf); in TEST()
796 char buf[BUFSIZ]; in TEST() local
798 snprintf(buf, sizeof(buf), "%e", 1.5); in TEST()
799 EXPECT_STREQ("1.500000e+00", buf); in TEST()
801 snprintf(buf, sizeof(buf), "%Le", 1.5L); in TEST()
802 EXPECT_STREQ("1.500000e+00", buf); in TEST()
806 char buf[BUFSIZ]; in TEST() local
808 snprintf(buf, sizeof(buf), "%e", -0.0); in TEST()
809 EXPECT_STREQ("-0.000000e+00", buf); in TEST()
810 snprintf(buf, sizeof(buf), "%E", -0.0); in TEST()
811 EXPECT_STREQ("-0.000000E+00", buf); in TEST()
812 snprintf(buf, sizeof(buf), "%f", -0.0); in TEST()
813 EXPECT_STREQ("-0.000000", buf); in TEST()
814 snprintf(buf, sizeof(buf), "%F", -0.0); in TEST()
815 EXPECT_STREQ("-0.000000", buf); in TEST()
816 snprintf(buf, sizeof(buf), "%g", -0.0); in TEST()
817 EXPECT_STREQ("-0", buf); in TEST()
818 snprintf(buf, sizeof(buf), "%G", -0.0); in TEST()
819 EXPECT_STREQ("-0", buf); in TEST()
820 snprintf(buf, sizeof(buf), "%a", -0.0); in TEST()
821 EXPECT_STREQ("-0x0p+0", buf); in TEST()
822 snprintf(buf, sizeof(buf), "%A", -0.0); in TEST()
823 EXPECT_STREQ("-0X0P+0", buf); in TEST()
831 char buf[BUFSIZ]; in TEST() local
834 snprintf(buf, sizeof(buf), "%dx%d", 1, 2); in TEST()
835 EXPECT_STREQ("1x2", buf); in TEST()
837 snprintf(buf, sizeof(buf), "%d\xc2\xa2%d", 1, 2); in TEST()
838 EXPECT_STREQ("1¢2", buf); in TEST()
840 snprintf(buf, sizeof(buf), "%d\xe2\x82\xac%d", 1, 2); in TEST()
841 EXPECT_STREQ("1€2", buf); in TEST()
843 snprintf(buf, sizeof(buf), "%d\xf0\xa4\xad\xa2%d", 1, 2); in TEST()
844 EXPECT_STREQ("12", buf); in TEST()
852 char buf[PATH_MAX]; in snprintf_small_stack_fn() local
853 snprintf(buf, sizeof(buf), "/proc/%d", getpid()); in snprintf_small_stack_fn()
870 char buf[128]; in TEST() local
871 ASSERT_EQ(5, snprintf(buf, sizeof(buf), "%.*s%c", 4, "hello world", '!')); in TEST()
872 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", INT_MAX/2, "hello world", '!')); in TEST()
873 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", INT_MAX-1, "hello world", '!')); in TEST()
874 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", INT_MAX, "hello world", '!')); in TEST()
875 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", -1, "hello world", '!')); in TEST()
878 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.2147483646s%c", "hello world", '!')); in TEST()
879 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.2147483647s%c", "hello world", '!')); in TEST()
880 ASSERT_EQ(-1, snprintf(buf, sizeof(buf), "%.2147483648s%c", "hello world", '!')); in TEST()
886 char buf[128]; in TEST() local
888 EXPECT_EQ(4, snprintf(buf, sizeof(buf), "<%*.*s>", 2, 2, null)); in TEST()
889 EXPECT_STREQ("<(n>", buf); in TEST()
890 EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%*.*s>", 2, 8, null)); in TEST()
891 EXPECT_STREQ("<(null)>", buf); in TEST()
892 EXPECT_EQ(10, snprintf(buf, sizeof(buf), "<%*.*s>", 8, 2, null)); in TEST()
893 EXPECT_STREQ("< (n>", buf); in TEST()
894 EXPECT_EQ(10, snprintf(buf, sizeof(buf), "<%*.*s>", 8, 8, null)); in TEST()
895 EXPECT_STREQ("< (null)>", buf); in TEST()
938 char buf[16]; in TEST() local
939 char* s = fgets(buf, sizeof(buf), fp); in TEST()
940 buf[13] = '\0'; in TEST()
953 char buf[16]; in TEST() local
954 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
955 EXPECT_STREQ("hello\n", buf); in TEST()
956 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
957 EXPECT_STREQ("world\n", buf); in TEST()
970 char buf[16]; in TEST() local
971 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
972 EXPECT_STREQ(" 4 a\n", buf); in TEST()
973 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
974 EXPECT_STREQ(" 1 b\n", buf); in TEST()
1064 char buf[256] = {}; in CheckScanf() local
1065 ASSERT_EQ(expected_count, sscanf_fn(input, fmt, &buf)) << fmt; in CheckScanf()
1066 ASSERT_STREQ(expected_string, buf) << fmt; in CheckScanf()
1259 char buf[BUFSIZ]; in TEST()
1262 memset(buf, 0, sizeof(buf)); in TEST()
1264 EXPECT_EQ(0, sscanf("\xc0" " foo", "%ls %s", wbuf, buf)); in TEST()
1269 char buf[4] = "x"; in TEST() local
1270 EXPECT_EQ(0, sscanf("d", "%[abc]", buf)); in TEST()
1271 EXPECT_EQ('x', buf[0]); in TEST()
1272 EXPECT_EQ(0, swscanf(L"d", L"%[abc]", buf)); in TEST()
1273 EXPECT_EQ('x', buf[0]); in TEST()
1279 EXPECT_EQ(EOF, sscanf("", "%s", buf)); in TEST()
1280 EXPECT_EQ('x', buf[0]); in TEST()
1288 wchar_t buf[BUFSIZ]; in TEST()
1291 memset(buf, 0, sizeof(buf)); in TEST()
1292 EXPECT_EQ(1, sscanf("xĀyz", "%l[xy]", buf)); in TEST()
1293 EXPECT_EQ(L"x"s, std::wstring(buf)); in TEST()
1294 memset(buf, 0, sizeof(buf)); in TEST()
1295 EXPECT_EQ(1, swscanf(L"xĀyz", L"%l[xy]", buf)); in TEST()
1296 EXPECT_EQ(L"x"s, std::wstring(buf)); in TEST()
1300 memset(buf, 0, sizeof(buf)); in TEST()
1301 EXPECT_EQ(1, sscanf("xĀyz", "%l[xĀy]", buf)); in TEST()
1302 EXPECT_EQ(L"x"s, std::wstring(buf)); in TEST()
1304 memset(buf, 0, sizeof(buf)); in TEST()
1305 EXPECT_EQ(1, swscanf(L"xĀyz", L"%l[xĀy]", buf)); in TEST()
1306 EXPECT_EQ(L"xĀy"s, std::wstring(buf)); in TEST()
1309 memset(buf, 0, sizeof(buf)); in TEST()
1310 EXPECT_EQ(1, sscanf("xĀyz", "%l[^ab]", buf)); in TEST()
1311 EXPECT_EQ(L"x"s, std::wstring(buf)); in TEST()
1313 memset(buf, 0, sizeof(buf)); in TEST()
1314 EXPECT_EQ(1, swscanf(L"xĀyz", L"%l[^ab]", buf)); in TEST()
1315 EXPECT_EQ(L"xĀyz"s, std::wstring(buf)); in TEST()
1318 memset(buf, 0, sizeof(buf)); in TEST()
1323 "%l[xy" "\xc5\x80" "\xc4\x81" "]", buf)); in TEST()
1324 EXPECT_EQ(L"x", std::wstring(buf)); in TEST()
1326 memset(buf, 0, sizeof(buf)); in TEST()
1331 L"%l[xy" L"\xc5\x80" L"\xc4\x81" L"]", buf)); in TEST()
1334 EXPECT_EQ(L"x" L"\xc4" L"\x80", std::wstring(buf)); in TEST()
1503 char buf[16]; in TEST() local
1504 memset(buf, 0, sizeof(buf)); in TEST()
1505 FILE* fp = fmemopen(buf, sizeof(buf), "r+"); in TEST()
1511 ASSERT_STREQ("<abc>\n", buf); in TEST()
1528 char buf[8]; in TEST() local
1533 memset(buf, 'x', sizeof(buf)); in TEST()
1534 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w")); in TEST()
1537 EXPECT_EQ("\0xxxxxxx"s, std::string(buf, buf + sizeof(buf))); in TEST()
1541 EXPECT_EQ("hello\0xx"s, std::string(buf, buf + sizeof(buf))); in TEST()
1544 EXPECT_EQ("hellowo\0"s, std::string(buf, buf + sizeof(buf))); in TEST()
1550 memset(buf, 'x', sizeof(buf)); in TEST()
1551 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "r+")); in TEST()
1554 EXPECT_EQ("xxxxxxxx"s, std::string(buf, buf + sizeof(buf))); in TEST()
1561 char buf[16]; in TEST() local
1562 memset(buf, 'x', sizeof(buf)); in TEST()
1570 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "r")); in TEST()
1578 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "r+")); in TEST()
1625 memset(buf, 'x', sizeof(buf)); in TEST()
1626 buf[3] = '\0'; in TEST()
1627 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a")); in TEST()
1635 memset(buf, 'x', sizeof(buf)); in TEST()
1636 buf[3] = '\0'; in TEST()
1637 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a+")); in TEST()
1648 memset(buf, 'x', sizeof(buf)); in TEST()
1649 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a")); in TEST()
1657 memset(buf, 'x', sizeof(buf)); in TEST()
1658 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a+")); in TEST()
1671 char buf[8]; in TEST() local
1672 memset(buf, 'x', sizeof(buf)); in TEST()
1673 strcpy(buf, "str"); in TEST()
1674 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w+")); in TEST()
1683 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w+")); in TEST()
1691 char buf[8]; in TEST() local
1692 memset(buf, 'x', sizeof(buf)); in TEST()
1693 FILE* fp = fmemopen(buf, sizeof(buf), "w"); in TEST()
1702 EXPECT_EQ(-1, fseek(fp, sizeof(buf) + 1, SEEK_SET)); in TEST()
1703 EXPECT_EQ(-1, fseeko(fp, sizeof(buf) + 1, SEEK_SET)); in TEST()
1709 char buf[8]; in TEST() local
1710 memset(buf, 'x', sizeof(buf)); in TEST()
1711 FILE* fp = fmemopen(buf, sizeof(buf), "r"); in TEST()
1724 char buf[] = "h\0e\0l\0l\0o"; in TEST() local
1725 FILE* fp = fmemopen(buf, sizeof(buf), "r"); in TEST()
1749 char buf[8]; in TEST() local
1753 memset(buf, 'x', sizeof(buf)); in TEST()
1754 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "r+")); in TEST()
1758 EXPECT_EQ("xx xxxxx", std::string(buf, buf + sizeof(buf))); in TEST()
1764 memset(buf, 'x', sizeof(buf)); in TEST()
1765 buf[3] = '\0'; in TEST()
1766 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a+")); in TEST()
1769 EXPECT_EQ("xxx \0xxx"s, std::string(buf, buf + sizeof(buf))); in TEST()
1776 memset(buf, 'x', sizeof(buf)); in TEST()
1777 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w+")); in TEST()
1787 EXPECT_EQ(" 123\0xxx"s, std::string(buf, buf + sizeof(buf))); in TEST()
1815 char buf[] = "hello\0world"; in TEST() local
1817 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "r")); in TEST()
1820 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w")); in TEST()
1823 buf[0] = 'h'; // (Undo the effects of the above.) in TEST()
1826 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a")); in TEST()
1832 memset(buf, 'x', sizeof(buf)); in TEST()
1833 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a")); in TEST()
1834 EXPECT_EQ(static_cast<long>(sizeof(buf)), ftell(fp)); in TEST()
1854 char buf[16]; in TEST() local
1855 ASSERT_NE(nullptr, fp = fmemopen(buf, 0, "r+")); in TEST()
1864 ASSERT_NE(nullptr, fp = fmemopen(buf, 0, "w+")); in TEST()
1875 char buf[2] = "x"; in TEST() local
1876 ASSERT_EQ('x', buf[0]); in TEST()
1877 FILE* fp = fmemopen(buf, 0, "w"); in TEST()
1878 ASSERT_EQ('x', buf[0]); in TEST()
1907 char buf[] = "hello\0world"; in TEST() local
1908 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a")); in TEST()
1912 EXPECT_EQ("hello!\0orld\0"s, std::string(buf, buf + sizeof(buf))); in TEST()
1915 memcpy(buf, "hello\0world", sizeof(buf)); in TEST()
1916 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a+")); in TEST()
1920 EXPECT_EQ("hello!\0orld\0"s, std::string(buf, buf + sizeof(buf))); in TEST()
2003 char buf[65*1024]; in TEST() local
2004 memset(buf, 0xff, sizeof(buf)); in TEST()
2008 ASSERT_EQ(1U, fread(buf, 64*1024, 1, fp)); in TEST()
2018 ASSERT_EQ('\0', buf[i]); in TEST()
2021 ASSERT_EQ('\xff', buf[i]); in TEST()
2050 std::vector<char> buf(n, 0); in test_fread_from_write_only_stream() local
2052 ASSERT_EQ(0U, fread(&buf[0], n, 1, fp)); in test_fread_from_write_only_stream()
2075 std::vector<char> buf(n, 0); in test_fwrite_after_fread() local
2076 ASSERT_EQ(0U, fread(&buf[0], 1, buf.size(), fp)); in test_fwrite_after_fread()
2085 ASSERT_EQ(2U, fread(&buf[0], 1, buf.size(), fp)); in test_fwrite_after_fread()
2086 ASSERT_EQ('1', buf[0]); in test_fwrite_after_fread()
2087 ASSERT_EQ('2', buf[1]); in test_fwrite_after_fread()
2141 char buf[6] = {0}; in TEST() local
2151 ASSERT_EQ(1U, fread(buf, 1, 1, fr)); in TEST()
2152 ASSERT_STREQ("a", buf); in TEST()
2155 ASSERT_EQ(0U, fread(buf, 1, 1, fr)); in TEST()
2164 ASSERT_EQ(1U, fread(buf, 1, 1, fr)); in TEST()
2165 ASSERT_STREQ("z", buf); in TEST()
2168 ASSERT_EQ(0U, fread(buf, 1, 1, fr)); in TEST()
2367 char buf[L_ctermid] = {}; in TEST() local
2368 ASSERT_EQ(buf, ctermid(buf)); in TEST()
2369 ASSERT_STREQ("/dev/tty", buf); in TEST()
2395 char buf[16]; in TEST() local
2396 ASSERT_EXIT(snprintf(buf, atol("-1"), "hello"), in TEST()
2407 std::string buf = "world"; in TEST() local
2408 ASSERT_EXIT(snprintf(&buf[0], atol("-1"), "hello"), in TEST()
2414 std::string buf = "world"; in TEST() local
2415 sprintf(&buf[0], "hello"); in TEST()
2416 ASSERT_EQ(buf, "hello"); in TEST()
2420 char buf[BUFSIZ]; in TEST() local
2422 snprintf(buf, sizeof(buf), "<%m>"); in TEST()
2423 ASSERT_STREQ("<Success>", buf); in TEST()
2425 snprintf(buf, sizeof(buf), "<%m>"); in TEST()
2426 ASSERT_STREQ("<Unknown error -1>", buf); in TEST()
2428 snprintf(buf, sizeof(buf), "<%m>"); in TEST()
2429 ASSERT_STREQ("<Invalid argument>", buf); in TEST()
2433 char buf[BUFSIZ]; in TEST() local
2437 snprintf(buf, sizeof(buf), "<%m>"); in TEST()
2438 ASSERT_STREQ("<Unknown error -2>", buf); in TEST()
2443 wchar_t buf[BUFSIZ]; in TEST() local
2445 swprintf(buf, sizeof(buf), L"<%m>"); in TEST()
2446 ASSERT_EQ(std::wstring(L"<Success>"), buf); in TEST()
2448 swprintf(buf, sizeof(buf), L"<%m>"); in TEST()
2449 ASSERT_EQ(std::wstring(L"<Unknown error -1>"), buf); in TEST()
2451 swprintf(buf, sizeof(buf), L"<%m>"); in TEST()
2452 ASSERT_EQ(std::wstring(L"<Invalid argument>"), buf); in TEST()
2456 wchar_t buf[BUFSIZ]; in TEST() local
2460 swprintf(buf, sizeof(buf), L"<%m>"); in TEST()
2461 ASSERT_EQ(std::wstring(L"<Unknown error -2>"), buf); in TEST()
2565 char buf[BUFSIZ] = {}; in TEST() local
2566 ASSERT_EQ(2U, fread_unlocked(&buf[0], 1, 2, fp)); in TEST()
2567 ASSERT_EQ(2U, fread(&buf[2], 1, 2, fp)); in TEST()
2568 ASSERT_STREQ("ABCD", buf); in TEST()
2576 ASSERT_TRUE(fgets_unlocked(buf, sizeof(buf), fp) != nullptr); in TEST()
2577 ASSERT_STREQ("hello world\n", buf); in TEST()