Lines Matching refs:buf
278 char buf[32]; in TEST() local
279 snprintf(buf, sizeof(buf), "%zd", v); in TEST()
284 char buf[BUFSIZ]; in TEST() local
285 EXPECT_EQ(23, snprintf(buf, sizeof(buf), "<%a>", 9990.235)); in TEST()
286 EXPECT_STREQ("<0x1.3831e147ae148p+13>", buf); in TEST()
290 char buf[BUFSIZ]; in TEST() local
292 EXPECT_EQ(3, snprintf(buf, sizeof(buf), "<%lc>", wc)); in TEST()
293 EXPECT_STREQ("<a>", buf); in TEST()
297 char buf[BUFSIZ]; in TEST() local
299 EXPECT_EQ(3, snprintf(buf, sizeof(buf), "<%C>", wc)); in TEST()
300 EXPECT_STREQ("<a>", buf); in TEST()
304 char buf[BUFSIZ]; in TEST() local
306 EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%ls>", ws)); in TEST()
307 EXPECT_STREQ("<(null)>", buf); in TEST()
311 EXPECT_EQ(4, snprintf(buf, sizeof(buf), "<%ls>", ws)); in TEST()
312 EXPECT_STREQ("<hi>", buf); in TEST()
316 char buf[BUFSIZ]; in TEST() local
318 EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%S>", ws)); in TEST()
319 EXPECT_STREQ("<(null)>", buf); in TEST()
323 EXPECT_EQ(4, snprintf(buf, sizeof(buf), "<%S>", ws)); in TEST()
324 EXPECT_STREQ("<hi>", buf); in TEST()
330 char buf[32]; in TEST() local
332 EXPECT_DEATH(snprintf(buf, sizeof(buf), "a %n b", &i), "%n not allowed on Android"); in TEST()
339 char buf[BUFSIZ]; in TEST() local
341 snprintf(buf, sizeof(buf), "a"); in TEST()
342 EXPECT_STREQ("a", buf); in TEST()
344 snprintf(buf, sizeof(buf), "%%"); in TEST()
345 EXPECT_STREQ("%", buf); in TEST()
347 snprintf(buf, sizeof(buf), "01234"); in TEST()
348 EXPECT_STREQ("01234", buf); in TEST()
350 snprintf(buf, sizeof(buf), "a%sb", "01234"); in TEST()
351 EXPECT_STREQ("a01234b", buf); in TEST()
354 snprintf(buf, sizeof(buf), "a%sb", s); in TEST()
355 EXPECT_STREQ("a(null)b", buf); in TEST()
357 snprintf(buf, sizeof(buf), "aa%scc", "bb"); in TEST()
358 EXPECT_STREQ("aabbcc", buf); in TEST()
360 snprintf(buf, sizeof(buf), "a%cc", 'b'); in TEST()
361 EXPECT_STREQ("abc", buf); in TEST()
363 snprintf(buf, sizeof(buf), "a%db", 1234); in TEST()
364 EXPECT_STREQ("a1234b", buf); in TEST()
366 snprintf(buf, sizeof(buf), "a%db", -8123); in TEST()
367 EXPECT_STREQ("a-8123b", buf); in TEST()
369 snprintf(buf, sizeof(buf), "a%hdb", static_cast<short>(0x7fff0010)); in TEST()
370 EXPECT_STREQ("a16b", buf); in TEST()
372 snprintf(buf, sizeof(buf), "a%hhdb", static_cast<char>(0x7fffff10)); in TEST()
373 EXPECT_STREQ("a16b", buf); in TEST()
375 snprintf(buf, sizeof(buf), "a%lldb", 0x1000000000LL); in TEST()
376 EXPECT_STREQ("a68719476736b", buf); in TEST()
378 snprintf(buf, sizeof(buf), "a%ldb", 70000L); in TEST()
379 EXPECT_STREQ("a70000b", buf); in TEST()
381 snprintf(buf, sizeof(buf), "a%pb", reinterpret_cast<void*>(0xb0001234)); in TEST()
382 EXPECT_STREQ("a0xb0001234b", buf); in TEST()
384 snprintf(buf, sizeof(buf), "a%xz", 0x12ab); in TEST()
385 EXPECT_STREQ("a12abz", buf); in TEST()
387 snprintf(buf, sizeof(buf), "a%Xz", 0x12ab); in TEST()
388 EXPECT_STREQ("a12ABz", buf); in TEST()
390 snprintf(buf, sizeof(buf), "a%08xz", 0x123456); in TEST()
391 EXPECT_STREQ("a00123456z", buf); in TEST()
393 snprintf(buf, sizeof(buf), "a%5dz", 1234); in TEST()
394 EXPECT_STREQ("a 1234z", buf); in TEST()
396 snprintf(buf, sizeof(buf), "a%05dz", 1234); in TEST()
397 EXPECT_STREQ("a01234z", buf); in TEST()
399 snprintf(buf, sizeof(buf), "a%8dz", 1234); in TEST()
400 EXPECT_STREQ("a 1234z", buf); in TEST()
402 snprintf(buf, sizeof(buf), "a%-8dz", 1234); in TEST()
403 EXPECT_STREQ("a1234 z", buf); in TEST()
405 snprintf(buf, sizeof(buf), "A%-11sZ", "abcdef"); in TEST()
406 EXPECT_STREQ("Aabcdef Z", buf); in TEST()
408 snprintf(buf, sizeof(buf), "A%s:%dZ", "hello", 1234); in TEST()
409 EXPECT_STREQ("Ahello:1234Z", buf); in TEST()
411 snprintf(buf, sizeof(buf), "a%03d:%d:%02dz", 5, 5, 5); in TEST()
412 EXPECT_STREQ("a005:5:05z", buf); in TEST()
415 snprintf(buf, sizeof(buf), "a%d,%pz", 5, p); in TEST()
417 EXPECT_STREQ("a5,0x0z", buf); in TEST()
419 EXPECT_STREQ("a5,(nil)z", buf); in TEST()
422 snprintf(buf, sizeof(buf), "a%lld,%d,%d,%dz", 0x1000000000LL, 6, 7, 8); in TEST()
423 EXPECT_STREQ("a68719476736,6,7,8z", buf); in TEST()
425 snprintf(buf, sizeof(buf), "a_%f_b", 1.23f); in TEST()
426 EXPECT_STREQ("a_1.230000_b", buf); in TEST()
428 snprintf(buf, sizeof(buf), "a_%g_b", 3.14); in TEST()
429 EXPECT_STREQ("a_3.14_b", buf); in TEST()
431 snprintf(buf, sizeof(buf), "%1$s %1$s", "print_me_twice"); in TEST()
432 EXPECT_STREQ("print_me_twice print_me_twice", buf); in TEST()
441 T buf[BUFSIZ]; in CheckInfNan() local
446 snprintf_fn(buf, sizeof(buf), fmt, nanf("")); in CheckInfNan()
447 EXPECT_STREQ(nan_, buf) << fmt; in CheckInfNan()
448 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
451 snprintf_fn(buf, sizeof(buf), fmt, -nanf("")); in CheckInfNan()
452 EXPECT_STREQ(minus_nan, buf) << fmt; in CheckInfNan()
453 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
456 snprintf_fn(buf, sizeof(buf), fmt_plus, nanf("")); in CheckInfNan()
457 EXPECT_STREQ(plus_nan, buf) << fmt_plus; in CheckInfNan()
458 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
461 snprintf_fn(buf, sizeof(buf), fmt_plus, -nanf("")); in CheckInfNan()
462 EXPECT_STREQ(minus_nan, buf) << fmt_plus; in CheckInfNan()
463 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
468 snprintf_fn(buf, sizeof(buf), fmt, HUGE_VALF); in CheckInfNan()
469 EXPECT_STREQ(inf_, buf) << fmt; in CheckInfNan()
470 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
473 snprintf_fn(buf, sizeof(buf), fmt, -HUGE_VALF); in CheckInfNan()
474 EXPECT_STREQ(minus_inf, buf) << fmt; in CheckInfNan()
475 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
478 snprintf_fn(buf, sizeof(buf), fmt_plus, HUGE_VALF); in CheckInfNan()
479 EXPECT_STREQ(plus_inf, buf) << fmt_plus; in CheckInfNan()
480 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
483 snprintf_fn(buf, sizeof(buf), fmt_plus, -HUGE_VALF); in CheckInfNan()
484 EXPECT_STREQ(minus_inf, buf) << fmt_plus; in CheckInfNan()
485 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)); in CheckInfNan()
489 snprintf_fn(buf, sizeof(buf), fmt_string, "[InFiNiTy]"); in CheckInfNan()
490 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)) << buf; in CheckInfNan()
492 snprintf_fn(buf, sizeof(buf), fmt_string, "[NaN]"); in CheckInfNan()
493 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)) << buf; in CheckInfNan()
569 wchar_t buf[nchars]; in TEST() local
571 ASSERT_EQ(2, swprintf(buf, nchars, L"ab")) << strerror(errno); in TEST()
572 ASSERT_EQ(std::wstring(L"ab"), buf); in TEST()
573 ASSERT_EQ(5, swprintf(buf, nchars, L"%s", "abcde")); in TEST()
574 ASSERT_EQ(std::wstring(L"abcde"), buf); in TEST()
578 ASSERT_EQ(-1, swprintf(buf, 4, L"%s", "abcde")); in TEST()
581 ASSERT_EQ(12, swprintf(buf, nchars, L"%s", kString)); in TEST()
582 ASSERT_EQ(std::wstring(L"Hello, World"), buf); in TEST()
583 ASSERT_EQ(12, swprintf(buf, 13, L"%s", kString)); in TEST()
584 ASSERT_EQ(std::wstring(L"Hello, World"), buf); in TEST()
589 wchar_t buf[nchars]; in TEST() local
591 ASSERT_EQ(20, swprintf(buf, nchars, L"%a", 3.1415926535)); in TEST()
592 ASSERT_EQ(std::wstring(L"0x1.921fb54411744p+1"), buf); in TEST()
597 wchar_t buf[nchars]; in TEST() local
600 EXPECT_EQ(3, swprintf(buf, nchars, L"<%lc>", wc)); in TEST()
601 EXPECT_EQ(std::wstring(L"<a>"), buf); in TEST()
606 wchar_t buf[nchars]; in TEST() local
609 EXPECT_EQ(3, swprintf(buf, nchars, L"<%C>", wc)); in TEST()
610 EXPECT_EQ(std::wstring(L"<a>"), buf); in TEST()
615 wchar_t buf[nchars]; in TEST() local
617 swprintf(buf, nchars, L"%jd", INTMAX_MAX); in TEST()
618 EXPECT_EQ(std::wstring(L"9223372036854775807"), buf); in TEST()
623 wchar_t buf[nchars]; in TEST() local
625 swprintf(buf, nchars, L"%jd", INTMAX_MIN); in TEST()
626 EXPECT_EQ(std::wstring(L"-9223372036854775808"), buf); in TEST()
631 wchar_t buf[nchars]; in TEST() local
633 swprintf(buf, nchars, L"%ju", UINTMAX_MAX); in TEST()
634 EXPECT_EQ(std::wstring(L"18446744073709551615"), buf); in TEST()
639 wchar_t buf[nchars]; in TEST() local
641 swprintf(buf, nchars, L"%1$ju", UINTMAX_MAX); in TEST()
642 EXPECT_EQ(std::wstring(L"18446744073709551615"), buf); in TEST()
647 wchar_t buf[nchars]; in TEST() local
650 ASSERT_EQ(12, swprintf(buf, nchars, L"%ls", kWideString)); in TEST()
651 ASSERT_EQ(std::wstring(kWideString), buf); in TEST()
652 ASSERT_EQ(12, swprintf(buf, 13, L"%ls", kWideString)); in TEST()
653 ASSERT_EQ(std::wstring(kWideString), buf); in TEST()
658 wchar_t buf[nchars]; in TEST() local
661 ASSERT_EQ(12, swprintf(buf, nchars, L"%S", kWideString)); in TEST()
662 ASSERT_EQ(std::wstring(kWideString), buf); in TEST()
663 ASSERT_EQ(12, swprintf(buf, 13, L"%S", kWideString)); in TEST()
664 ASSERT_EQ(std::wstring(kWideString), buf); in TEST()
668 char buf[BUFSIZ]; in TEST() local
669 snprintf(buf, sizeof(buf), "%d", INT_MAX); in TEST()
670 EXPECT_STREQ("2147483647", buf); in TEST()
674 char buf[BUFSIZ]; in TEST() local
675 snprintf(buf, sizeof(buf), "%d", INT_MIN); in TEST()
676 EXPECT_STREQ("-2147483648", buf); in TEST()
680 char buf[BUFSIZ]; in TEST() local
681 snprintf(buf, sizeof(buf), "%jd", INTMAX_MAX); in TEST()
682 EXPECT_STREQ("9223372036854775807", buf); in TEST()
686 char buf[BUFSIZ]; in TEST() local
687 snprintf(buf, sizeof(buf), "%jd", INTMAX_MIN); in TEST()
688 EXPECT_STREQ("-9223372036854775808", buf); in TEST()
692 char buf[BUFSIZ]; in TEST() local
693 snprintf(buf, sizeof(buf), "%ju", UINTMAX_MAX); in TEST()
694 EXPECT_STREQ("18446744073709551615", buf); in TEST()
698 char buf[BUFSIZ]; in TEST() local
699 snprintf(buf, sizeof(buf), "%1$ju", UINTMAX_MAX); in TEST()
700 EXPECT_STREQ("18446744073709551615", buf); in TEST()
704 char buf[BUFSIZ]; in TEST() local
705 snprintf(buf, sizeof(buf), "%ld", LONG_MAX); in TEST()
707 EXPECT_STREQ("9223372036854775807", buf); in TEST()
709 EXPECT_STREQ("2147483647", buf); in TEST()
714 char buf[BUFSIZ]; in TEST() local
715 snprintf(buf, sizeof(buf), "%ld", LONG_MIN); in TEST()
717 EXPECT_STREQ("-9223372036854775808", buf); in TEST()
719 EXPECT_STREQ("-2147483648", buf); in TEST()
724 char buf[BUFSIZ]; in TEST() local
725 snprintf(buf, sizeof(buf), "%lld", LLONG_MAX); in TEST()
726 EXPECT_STREQ("9223372036854775807", buf); in TEST()
730 char buf[BUFSIZ]; in TEST() local
731 snprintf(buf, sizeof(buf), "%lld", LLONG_MIN); in TEST()
732 EXPECT_STREQ("-9223372036854775808", buf); in TEST()
736 char buf[BUFSIZ]; in TEST() local
737 snprintf(buf, sizeof(buf), "%o", UINT_MAX); in TEST()
738 EXPECT_STREQ("37777777777", buf); in TEST()
742 char buf[BUFSIZ]; in TEST() local
743 snprintf(buf, sizeof(buf), "%u", UINT_MAX); in TEST()
744 EXPECT_STREQ("4294967295", buf); in TEST()
748 char buf[BUFSIZ]; in TEST() local
749 snprintf(buf, sizeof(buf), "%x", UINT_MAX); in TEST()
750 EXPECT_STREQ("ffffffff", buf); in TEST()
754 char buf[BUFSIZ]; in TEST() local
755 snprintf(buf, sizeof(buf), "%X", UINT_MAX); in TEST()
756 EXPECT_STREQ("FFFFFFFF", buf); in TEST()
760 char buf[BUFSIZ]; in TEST() local
762 snprintf(buf, sizeof(buf), "%e", 1.5); in TEST()
763 EXPECT_STREQ("1.500000e+00", buf); in TEST()
765 snprintf(buf, sizeof(buf), "%Le", 1.5L); in TEST()
766 EXPECT_STREQ("1.500000e+00", buf); in TEST()
770 char buf[BUFSIZ]; in TEST() local
772 snprintf(buf, sizeof(buf), "%e", -0.0); in TEST()
773 EXPECT_STREQ("-0.000000e+00", buf); in TEST()
774 snprintf(buf, sizeof(buf), "%E", -0.0); in TEST()
775 EXPECT_STREQ("-0.000000E+00", buf); in TEST()
776 snprintf(buf, sizeof(buf), "%f", -0.0); in TEST()
777 EXPECT_STREQ("-0.000000", buf); in TEST()
778 snprintf(buf, sizeof(buf), "%F", -0.0); in TEST()
779 EXPECT_STREQ("-0.000000", buf); in TEST()
780 snprintf(buf, sizeof(buf), "%g", -0.0); in TEST()
781 EXPECT_STREQ("-0", buf); in TEST()
782 snprintf(buf, sizeof(buf), "%G", -0.0); in TEST()
783 EXPECT_STREQ("-0", buf); in TEST()
784 snprintf(buf, sizeof(buf), "%a", -0.0); in TEST()
785 EXPECT_STREQ("-0x0p+0", buf); in TEST()
786 snprintf(buf, sizeof(buf), "%A", -0.0); in TEST()
787 EXPECT_STREQ("-0X0P+0", buf); in TEST()
795 char buf[BUFSIZ]; in TEST() local
798 snprintf(buf, sizeof(buf), "%dx%d", 1, 2); in TEST()
799 EXPECT_STREQ("1x2", buf); in TEST()
801 snprintf(buf, sizeof(buf), "%d\xc2\xa2%d", 1, 2); in TEST()
802 EXPECT_STREQ("1¢2", buf); in TEST()
804 snprintf(buf, sizeof(buf), "%d\xe2\x82\xac%d", 1, 2); in TEST()
805 EXPECT_STREQ("1€2", buf); in TEST()
807 snprintf(buf, sizeof(buf), "%d\xf0\xa4\xad\xa2%d", 1, 2); in TEST()
808 EXPECT_STREQ("12", buf); in TEST()
816 char buf[PATH_MAX]; in snprintf_small_stack_fn() local
817 snprintf(buf, sizeof(buf), "/proc/%d", getpid()); in snprintf_small_stack_fn()
834 char buf[128]; in TEST() local
835 ASSERT_EQ(5, snprintf(buf, sizeof(buf), "%.*s%c", 4, "hello world", '!')); in TEST()
836 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", INT_MAX/2, "hello world", '!')); in TEST()
837 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", INT_MAX-1, "hello world", '!')); in TEST()
838 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", INT_MAX, "hello world", '!')); in TEST()
839 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", -1, "hello world", '!')); in TEST()
842 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.2147483646s%c", "hello world", '!')); in TEST()
843 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.2147483647s%c", "hello world", '!')); in TEST()
844 ASSERT_EQ(-1, snprintf(buf, sizeof(buf), "%.2147483648s%c", "hello world", '!')); in TEST()
888 char buf[16]; in TEST() local
889 char* s = fgets(buf, sizeof(buf), fp); in TEST()
890 buf[13] = '\0'; in TEST()
903 char buf[16]; in TEST() local
904 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
905 EXPECT_STREQ("hello\n", buf); in TEST()
906 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
907 EXPECT_STREQ("world\n", buf); in TEST()
920 char buf[16]; in TEST() local
921 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
922 EXPECT_STREQ(" 4 a\n", buf); in TEST()
923 ASSERT_NE(nullptr, fgets(buf, sizeof(buf), fp)); in TEST()
924 EXPECT_STREQ(" 1 b\n", buf); in TEST()
1014 char buf[256] = {}; in CheckScanf() local
1015 ASSERT_EQ(expected_count, sscanf_fn(input, fmt, &buf)) << fmt; in CheckScanf()
1016 ASSERT_STREQ(expected_string, buf) << fmt; in CheckScanf()
1209 char buf[BUFSIZ]; in TEST()
1212 memset(buf, 0, sizeof(buf)); in TEST()
1214 EXPECT_EQ(0, sscanf("\xc0" " foo", "%ls %s", wbuf, buf)); in TEST()
1219 char buf[4] = "x"; in TEST() local
1220 EXPECT_EQ(0, sscanf("d", "%[abc]", buf)); in TEST()
1221 EXPECT_EQ('x', buf[0]); in TEST()
1222 EXPECT_EQ(0, swscanf(L"d", L"%[abc]", buf)); in TEST()
1223 EXPECT_EQ('x', buf[0]); in TEST()
1229 EXPECT_EQ(EOF, sscanf("", "%s", buf)); in TEST()
1230 EXPECT_EQ('x', buf[0]); in TEST()
1238 wchar_t buf[BUFSIZ]; in TEST()
1241 memset(buf, 0, sizeof(buf)); in TEST()
1242 EXPECT_EQ(1, sscanf("xĀyz", "%l[xy]", buf)); in TEST()
1243 EXPECT_EQ(L"x"s, std::wstring(buf)); in TEST()
1244 memset(buf, 0, sizeof(buf)); in TEST()
1245 EXPECT_EQ(1, swscanf(L"xĀyz", L"%l[xy]", buf)); in TEST()
1246 EXPECT_EQ(L"x"s, std::wstring(buf)); in TEST()
1250 memset(buf, 0, sizeof(buf)); in TEST()
1251 EXPECT_EQ(1, sscanf("xĀyz", "%l[xĀy]", buf)); in TEST()
1252 EXPECT_EQ(L"x"s, std::wstring(buf)); in TEST()
1254 memset(buf, 0, sizeof(buf)); in TEST()
1255 EXPECT_EQ(1, swscanf(L"xĀyz", L"%l[xĀy]", buf)); in TEST()
1256 EXPECT_EQ(L"xĀy"s, std::wstring(buf)); in TEST()
1259 memset(buf, 0, sizeof(buf)); in TEST()
1260 EXPECT_EQ(1, sscanf("xĀyz", "%l[^ab]", buf)); in TEST()
1261 EXPECT_EQ(L"x"s, std::wstring(buf)); in TEST()
1263 memset(buf, 0, sizeof(buf)); in TEST()
1264 EXPECT_EQ(1, swscanf(L"xĀyz", L"%l[^ab]", buf)); in TEST()
1265 EXPECT_EQ(L"xĀyz"s, std::wstring(buf)); in TEST()
1268 memset(buf, 0, sizeof(buf)); in TEST()
1273 "%l[xy" "\xc5\x80" "\xc4\x81" "]", buf)); in TEST()
1274 EXPECT_EQ(L"x", std::wstring(buf)); in TEST()
1276 memset(buf, 0, sizeof(buf)); in TEST()
1281 L"%l[xy" L"\xc5\x80" L"\xc4\x81" L"]", buf)); in TEST()
1284 EXPECT_EQ(L"x" L"\xc4" L"\x80", std::wstring(buf)); in TEST()
1453 char buf[16]; in TEST() local
1454 memset(buf, 0, sizeof(buf)); in TEST()
1455 FILE* fp = fmemopen(buf, sizeof(buf), "r+"); in TEST()
1461 ASSERT_STREQ("<abc>\n", buf); in TEST()
1478 char buf[8]; in TEST() local
1483 memset(buf, 'x', sizeof(buf)); in TEST()
1484 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w")); in TEST()
1487 EXPECT_EQ("\0xxxxxxx"s, std::string(buf, buf + sizeof(buf))); in TEST()
1491 EXPECT_EQ("hello\0xx"s, std::string(buf, buf + sizeof(buf))); in TEST()
1494 EXPECT_EQ("hellowo\0"s, std::string(buf, buf + sizeof(buf))); in TEST()
1500 memset(buf, 'x', sizeof(buf)); in TEST()
1501 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "r+")); in TEST()
1504 EXPECT_EQ("xxxxxxxx"s, std::string(buf, buf + sizeof(buf))); in TEST()
1511 char buf[16]; in TEST() local
1512 memset(buf, 'x', sizeof(buf)); in TEST()
1520 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "r")); in TEST()
1528 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "r+")); in TEST()
1575 memset(buf, 'x', sizeof(buf)); in TEST()
1576 buf[3] = '\0'; in TEST()
1577 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a")); in TEST()
1585 memset(buf, 'x', sizeof(buf)); in TEST()
1586 buf[3] = '\0'; in TEST()
1587 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a+")); in TEST()
1598 memset(buf, 'x', sizeof(buf)); in TEST()
1599 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a")); in TEST()
1607 memset(buf, 'x', sizeof(buf)); in TEST()
1608 ASSERT_NE(nullptr, fp = fmemopen(buf, 16, "a+")); in TEST()
1621 char buf[8]; in TEST() local
1622 memset(buf, 'x', sizeof(buf)); in TEST()
1623 strcpy(buf, "str"); in TEST()
1624 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w+")); in TEST()
1633 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w+")); in TEST()
1641 char buf[8]; in TEST() local
1642 memset(buf, 'x', sizeof(buf)); in TEST()
1643 FILE* fp = fmemopen(buf, sizeof(buf), "w"); in TEST()
1652 EXPECT_EQ(-1, fseek(fp, sizeof(buf) + 1, SEEK_SET)); in TEST()
1653 EXPECT_EQ(-1, fseeko(fp, sizeof(buf) + 1, SEEK_SET)); in TEST()
1659 char buf[8]; in TEST() local
1660 memset(buf, 'x', sizeof(buf)); in TEST()
1661 FILE* fp = fmemopen(buf, sizeof(buf), "r"); in TEST()
1674 char buf[] = "h\0e\0l\0l\0o"; in TEST() local
1675 FILE* fp = fmemopen(buf, sizeof(buf), "r"); in TEST()
1699 char buf[8]; in TEST() local
1703 memset(buf, 'x', sizeof(buf)); in TEST()
1704 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "r+")); in TEST()
1708 EXPECT_EQ("xx xxxxx", std::string(buf, buf + sizeof(buf))); in TEST()
1714 memset(buf, 'x', sizeof(buf)); in TEST()
1715 buf[3] = '\0'; in TEST()
1716 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a+")); in TEST()
1719 EXPECT_EQ("xxx \0xxx"s, std::string(buf, buf + sizeof(buf))); in TEST()
1726 memset(buf, 'x', sizeof(buf)); in TEST()
1727 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w+")); in TEST()
1737 EXPECT_EQ(" 123\0xxx"s, std::string(buf, buf + sizeof(buf))); in TEST()
1765 char buf[] = "hello\0world"; in TEST() local
1767 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "r")); in TEST()
1770 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "w")); in TEST()
1773 buf[0] = 'h'; // (Undo the effects of the above.) in TEST()
1776 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a")); in TEST()
1782 memset(buf, 'x', sizeof(buf)); in TEST()
1783 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a")); in TEST()
1784 EXPECT_EQ(static_cast<long>(sizeof(buf)), ftell(fp)); in TEST()
1804 char buf[16]; in TEST() local
1805 ASSERT_NE(nullptr, fp = fmemopen(buf, 0, "r+")); in TEST()
1814 ASSERT_NE(nullptr, fp = fmemopen(buf, 0, "w+")); in TEST()
1825 char buf[2] = "x"; in TEST() local
1826 ASSERT_EQ('x', buf[0]); in TEST()
1827 FILE* fp = fmemopen(buf, 0, "w"); in TEST()
1828 ASSERT_EQ('x', buf[0]); in TEST()
1857 char buf[] = "hello\0world"; in TEST() local
1858 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a")); in TEST()
1862 EXPECT_EQ("hello!\0orld\0"s, std::string(buf, buf + sizeof(buf))); in TEST()
1865 memcpy(buf, "hello\0world", sizeof(buf)); in TEST()
1866 ASSERT_NE(nullptr, fp = fmemopen(buf, sizeof(buf), "a+")); in TEST()
1870 EXPECT_EQ("hello!\0orld\0"s, std::string(buf, buf + sizeof(buf))); in TEST()
1953 char buf[65*1024]; in TEST() local
1954 memset(buf, 0xff, sizeof(buf)); in TEST()
1958 ASSERT_EQ(1U, fread(buf, 64*1024, 1, fp)); in TEST()
1968 ASSERT_EQ('\0', buf[i]); in TEST()
1971 ASSERT_EQ('\xff', buf[i]); in TEST()
2000 std::vector<char> buf(n, 0); in test_fread_from_write_only_stream() local
2002 ASSERT_EQ(0U, fread(&buf[0], n, 1, fp)); in test_fread_from_write_only_stream()
2025 std::vector<char> buf(n, 0); in test_fwrite_after_fread() local
2026 ASSERT_EQ(0U, fread(&buf[0], 1, buf.size(), fp)); in test_fwrite_after_fread()
2035 ASSERT_EQ(2U, fread(&buf[0], 1, buf.size(), fp)); in test_fwrite_after_fread()
2036 ASSERT_EQ('1', buf[0]); in test_fwrite_after_fread()
2037 ASSERT_EQ('2', buf[1]); in test_fwrite_after_fread()
2091 char buf[6] = {0}; in TEST() local
2101 ASSERT_EQ(1U, fread(buf, 1, 1, fr)); in TEST()
2102 ASSERT_STREQ("a", buf); in TEST()
2105 ASSERT_EQ(0U, fread(buf, 1, 1, fr)); in TEST()
2114 ASSERT_EQ(1U, fread(buf, 1, 1, fr)); in TEST()
2115 ASSERT_STREQ("z", buf); in TEST()
2118 ASSERT_EQ(0U, fread(buf, 1, 1, fr)); in TEST()
2317 char buf[L_ctermid] = {}; in TEST() local
2318 ASSERT_EQ(buf, ctermid(buf)); in TEST()
2319 ASSERT_STREQ("/dev/tty", buf); in TEST()
2345 char buf[16]; in TEST() local
2346 ASSERT_EXIT(snprintf(buf, atol("-1"), "hello"), in TEST()
2357 std::string buf = "world"; in TEST() local
2358 ASSERT_EXIT(snprintf(&buf[0], atol("-1"), "hello"), in TEST()
2364 std::string buf = "world"; in TEST() local
2365 sprintf(&buf[0], "hello"); in TEST()
2366 ASSERT_EQ(buf, "hello"); in TEST()
2370 char buf[BUFSIZ]; in TEST() local
2372 snprintf(buf, sizeof(buf), "<%m>"); in TEST()
2373 ASSERT_STREQ("<Success>", buf); in TEST()
2375 snprintf(buf, sizeof(buf), "<%m>"); in TEST()
2376 ASSERT_STREQ("<Unknown error -1>", buf); in TEST()
2378 snprintf(buf, sizeof(buf), "<%m>"); in TEST()
2379 ASSERT_STREQ("<Invalid argument>", buf); in TEST()
2383 char buf[BUFSIZ]; in TEST() local
2387 snprintf(buf, sizeof(buf), "<%m>"); in TEST()
2388 ASSERT_STREQ("<Unknown error -2>", buf); in TEST()
2393 wchar_t buf[BUFSIZ]; in TEST() local
2395 swprintf(buf, sizeof(buf), L"<%m>"); in TEST()
2396 ASSERT_EQ(std::wstring(L"<Success>"), buf); in TEST()
2398 swprintf(buf, sizeof(buf), L"<%m>"); in TEST()
2399 ASSERT_EQ(std::wstring(L"<Unknown error -1>"), buf); in TEST()
2401 swprintf(buf, sizeof(buf), L"<%m>"); in TEST()
2402 ASSERT_EQ(std::wstring(L"<Invalid argument>"), buf); in TEST()
2406 wchar_t buf[BUFSIZ]; in TEST() local
2410 swprintf(buf, sizeof(buf), L"<%m>"); in TEST()
2411 ASSERT_EQ(std::wstring(L"<Unknown error -2>"), buf); in TEST()
2515 char buf[BUFSIZ] = {}; in TEST() local
2516 ASSERT_EQ(2U, fread_unlocked(&buf[0], 1, 2, fp)); in TEST()
2517 ASSERT_EQ(2U, fread(&buf[2], 1, 2, fp)); in TEST()
2518 ASSERT_STREQ("ABCD", buf); in TEST()
2526 ASSERT_TRUE(fgets_unlocked(buf, sizeof(buf), fp) != nullptr); in TEST()
2527 ASSERT_STREQ("hello world\n", buf); in TEST()