Lines Matching refs:buf

266   char buf[32];
267 snprintf(buf, sizeof(buf), "%zd", v);
272 char buf[BUFSIZ];
273 EXPECT_EQ(23, snprintf(buf, sizeof(buf), "<%a>", 9990.235));
274 EXPECT_STREQ("<0x1.3831e147ae148p+13>", buf);
278 char buf[BUFSIZ];
280 EXPECT_EQ(3, snprintf(buf, sizeof(buf), "<%lc>", wc));
281 EXPECT_STREQ("<a>", buf);
285 char buf[BUFSIZ];
287 EXPECT_EQ(8, snprintf(buf, sizeof(buf), "<%ls>", ws));
288 EXPECT_STREQ("<(null)>", buf);
292 EXPECT_EQ(4, snprintf(buf, sizeof(buf), "<%ls>", ws));
293 EXPECT_STREQ("<hi>", buf);
299 char buf[32];
301 EXPECT_EQ(5, snprintf(buf, sizeof(buf), "a %n b", &i));
303 EXPECT_STREQ("a n b", buf);
310 char buf[BUFSIZ];
312 snprintf(buf, sizeof(buf), "a");
313 EXPECT_STREQ("a", buf);
315 snprintf(buf, sizeof(buf), "%%");
316 EXPECT_STREQ("%", buf);
318 snprintf(buf, sizeof(buf), "01234");
319 EXPECT_STREQ("01234", buf);
321 snprintf(buf, sizeof(buf), "a%sb", "01234");
322 EXPECT_STREQ("a01234b", buf);
325 snprintf(buf, sizeof(buf), "a%sb", s);
326 EXPECT_STREQ("a(null)b", buf);
328 snprintf(buf, sizeof(buf), "aa%scc", "bb");
329 EXPECT_STREQ("aabbcc", buf);
331 snprintf(buf, sizeof(buf), "a%cc", 'b');
332 EXPECT_STREQ("abc", buf);
334 snprintf(buf, sizeof(buf), "a%db", 1234);
335 EXPECT_STREQ("a1234b", buf);
337 snprintf(buf, sizeof(buf), "a%db", -8123);
338 EXPECT_STREQ("a-8123b", buf);
340 snprintf(buf, sizeof(buf), "a%hdb", static_cast<short>(0x7fff0010));
341 EXPECT_STREQ("a16b", buf);
343 snprintf(buf, sizeof(buf), "a%hhdb", static_cast<char>(0x7fffff10));
344 EXPECT_STREQ("a16b", buf);
346 snprintf(buf, sizeof(buf), "a%lldb", 0x1000000000LL);
347 EXPECT_STREQ("a68719476736b", buf);
349 snprintf(buf, sizeof(buf), "a%ldb", 70000L);
350 EXPECT_STREQ("a70000b", buf);
352 snprintf(buf, sizeof(buf), "a%pb", reinterpret_cast<void*>(0xb0001234));
353 EXPECT_STREQ("a0xb0001234b", buf);
355 snprintf(buf, sizeof(buf), "a%xz", 0x12ab);
356 EXPECT_STREQ("a12abz", buf);
358 snprintf(buf, sizeof(buf), "a%Xz", 0x12ab);
359 EXPECT_STREQ("a12ABz", buf);
361 snprintf(buf, sizeof(buf), "a%08xz", 0x123456);
362 EXPECT_STREQ("a00123456z", buf);
364 snprintf(buf, sizeof(buf), "a%5dz", 1234);
365 EXPECT_STREQ("a 1234z", buf);
367 snprintf(buf, sizeof(buf), "a%05dz", 1234);
368 EXPECT_STREQ("a01234z", buf);
370 snprintf(buf, sizeof(buf), "a%8dz", 1234);
371 EXPECT_STREQ("a 1234z", buf);
373 snprintf(buf, sizeof(buf), "a%-8dz", 1234);
374 EXPECT_STREQ("a1234 z", buf);
376 snprintf(buf, sizeof(buf), "A%-11sZ", "abcdef");
377 EXPECT_STREQ("Aabcdef Z", buf);
379 snprintf(buf, sizeof(buf), "A%s:%dZ", "hello", 1234);
380 EXPECT_STREQ("Ahello:1234Z", buf);
382 snprintf(buf, sizeof(buf), "a%03d:%d:%02dz", 5, 5, 5);
383 EXPECT_STREQ("a005:5:05z", buf);
386 snprintf(buf, sizeof(buf), "a%d,%pz", 5, p);
388 EXPECT_STREQ("a5,0x0z", buf);
390 EXPECT_STREQ("a5,(nil)z", buf);
393 snprintf(buf, sizeof(buf), "a%lld,%d,%d,%dz", 0x1000000000LL, 6, 7, 8);
394 EXPECT_STREQ("a68719476736,6,7,8z", buf);
396 snprintf(buf, sizeof(buf), "a_%f_b", 1.23f);
397 EXPECT_STREQ("a_1.230000_b", buf);
399 snprintf(buf, sizeof(buf), "a_%g_b", 3.14);
400 EXPECT_STREQ("a_3.14_b", buf);
402 snprintf(buf, sizeof(buf), "%1$s %1$s", "print_me_twice");
403 EXPECT_STREQ("print_me_twice print_me_twice", buf);
412 T buf[BUFSIZ];
417 snprintf_fn(buf, sizeof(buf), fmt, nanf(""));
418 EXPECT_STREQ(nan_, buf) << fmt;
419 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
422 snprintf_fn(buf, sizeof(buf), fmt, -nanf(""));
423 EXPECT_STREQ(minus_nan, buf) << fmt;
424 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
427 snprintf_fn(buf, sizeof(buf), fmt_plus, nanf(""));
428 EXPECT_STREQ(plus_nan, buf) << fmt_plus;
429 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
432 snprintf_fn(buf, sizeof(buf), fmt_plus, -nanf(""));
433 EXPECT_STREQ(minus_nan, buf) << fmt_plus;
434 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
439 snprintf_fn(buf, sizeof(buf), fmt, HUGE_VALF);
440 EXPECT_STREQ(inf_, buf) << fmt;
441 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
444 snprintf_fn(buf, sizeof(buf), fmt, -HUGE_VALF);
445 EXPECT_STREQ(minus_inf, buf) << fmt;
446 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
449 snprintf_fn(buf, sizeof(buf), fmt_plus, HUGE_VALF);
450 EXPECT_STREQ(plus_inf, buf) << fmt_plus;
451 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
454 snprintf_fn(buf, sizeof(buf), fmt_plus, -HUGE_VALF);
455 EXPECT_STREQ(minus_inf, buf) << fmt_plus;
456 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f));
460 snprintf_fn(buf, sizeof(buf), fmt_string, "[InFiNiTy]");
461 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)) << buf;
463 snprintf_fn(buf, sizeof(buf), fmt_string, "[NaN]");
464 EXPECT_EQ(1, sscanf_fn(buf, fmt, &f)) << buf;
539 char buf[BUFSIZ];
540 snprintf(buf, sizeof(buf), "%d", INT_MAX);
541 EXPECT_STREQ("2147483647", buf);
545 char buf[BUFSIZ];
546 snprintf(buf, sizeof(buf), "%d", INT_MIN);
547 EXPECT_STREQ("-2147483648", buf);
551 char buf[BUFSIZ];
552 snprintf(buf, sizeof(buf), "%ld", LONG_MAX);
554 EXPECT_STREQ("9223372036854775807", buf);
556 EXPECT_STREQ("2147483647", buf);
561 char buf[BUFSIZ];
562 snprintf(buf, sizeof(buf), "%ld", LONG_MIN);
564 EXPECT_STREQ("-9223372036854775808", buf);
566 EXPECT_STREQ("-2147483648", buf);
571 char buf[BUFSIZ];
572 snprintf(buf, sizeof(buf), "%lld", LLONG_MAX);
573 EXPECT_STREQ("9223372036854775807", buf);
577 char buf[BUFSIZ];
578 snprintf(buf, sizeof(buf), "%lld", LLONG_MIN);
579 EXPECT_STREQ("-9223372036854775808", buf);
583 char buf[BUFSIZ];
585 snprintf(buf, sizeof(buf), "%e", 1.5);
586 EXPECT_STREQ("1.500000e+00", buf);
588 snprintf(buf, sizeof(buf), "%Le", 1.5l);
589 EXPECT_STREQ("1.500000e+00", buf);
593 char buf[BUFSIZ];
595 snprintf(buf, sizeof(buf), "%e", -0.0);
596 EXPECT_STREQ("-0.000000e+00", buf);
597 snprintf(buf, sizeof(buf), "%E", -0.0);
598 EXPECT_STREQ("-0.000000E+00", buf);
599 snprintf(buf, sizeof(buf), "%f", -0.0);
600 EXPECT_STREQ("-0.000000", buf);
601 snprintf(buf, sizeof(buf), "%F", -0.0);
602 EXPECT_STREQ("-0.000000", buf);
603 snprintf(buf, sizeof(buf), "%g", -0.0);
604 EXPECT_STREQ("-0", buf);
605 snprintf(buf, sizeof(buf), "%G", -0.0);
606 EXPECT_STREQ("-0", buf);
607 snprintf(buf, sizeof(buf), "%a", -0.0);
608 EXPECT_STREQ("-0x0p+0", buf);
609 snprintf(buf, sizeof(buf), "%A", -0.0);
610 EXPECT_STREQ("-0X0P+0", buf);
618 char buf[BUFSIZ];
621 snprintf(buf, sizeof(buf), "%dx%d", 1, 2);
622 EXPECT_STREQ("1x2", buf);
624 snprintf(buf, sizeof(buf), "%d\xc2\xa2%d", 1, 2);
625 EXPECT_STREQ("1¢2", buf);
627 snprintf(buf, sizeof(buf), "%d\xe2\x82\xac%d", 1, 2);
628 EXPECT_STREQ("1€2", buf);
630 snprintf(buf, sizeof(buf), "%d\xf0\xa4\xad\xa2%d", 1, 2);
631 EXPECT_STREQ("1𤭢2", buf);
639 char buf[PATH_MAX];
640 snprintf(buf, sizeof(buf), "/proc/%d", getpid());
657 char buf[128];
658 ASSERT_EQ(5, snprintf(buf, sizeof(buf), "%.*s%c", 4, "hello world", '!'));
659 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", INT_MAX/2, "hello world", '!'));
660 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", INT_MAX-1, "hello world", '!'));
661 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", INT_MAX, "hello world", '!'));
662 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.*s%c", -1, "hello world", '!'));
665 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.2147483646s%c", "hello world", '!'));
666 ASSERT_EQ(12, snprintf(buf, sizeof(buf), "%.2147483647s%c", "hello world", '!'));
667 ASSERT_EQ(-1, snprintf(buf, sizeof(buf), "%.2147483648s%c", "hello world", '!'));
709 char buf[16];
710 char* s = fgets(buf, sizeof(buf), fp);
711 buf[13] = '\0';
930 char buf[16];
931 memset(buf, 0, sizeof(buf));
932 FILE* fp = fmemopen(buf, sizeof(buf), "r+");
937 ASSERT_STREQ("<abc>\n", buf);
952 char buf[16];
956 ASSERT_EQ(nullptr, fmemopen(buf, 0, "r+"));
1053 char buf[65*1024];
1054 memset(buf, 0xff, sizeof(buf));
1058 ASSERT_EQ(1U, fread(buf, 64*1024, 1, fp));
1068 ASSERT_EQ('\0', buf[i]);
1071 ASSERT_EQ('\xff', buf[i]);
1100 std::vector<char> buf(n, 0);
1102 ASSERT_EQ(0U, fread(&buf[0], n, 1, fp));
1125 std::vector<char> buf(n, 0);
1126 ASSERT_EQ(0U, fread(&buf[0], 1, buf.size(), fp));
1135 ASSERT_EQ(2U, fread(&buf[0], 1, buf.size(), fp));
1136 ASSERT_EQ('1', buf[0]);
1137 ASSERT_EQ('2', buf[1]);
1191 char buf[6] = {0};
1201 ASSERT_EQ(1U, fread(buf, 1, 1, fr));
1202 ASSERT_STREQ("a", buf);
1205 ASSERT_EQ(0U, fread(buf, 1, 1, fr));
1214 ASSERT_EQ(1U, fread(buf, 1, 1, fr));
1215 ASSERT_STREQ("z", buf);
1218 ASSERT_EQ(0U, fread(buf, 1, 1, fr));
1417 char buf[L_ctermid] = {};
1418 ASSERT_EQ(buf, ctermid(buf));
1419 ASSERT_STREQ("/dev/tty", buf);
1445 char buf[16];
1446 ASSERT_EXIT(snprintf(buf, atol("-1"), "hello"),
1457 std::string buf = "world";
1458 ASSERT_EXIT(snprintf(&buf[0], atol("-1"), "hello"),
1464 std::string buf = "world";
1465 sprintf(&buf[0], "hello");
1466 ASSERT_EQ(buf, "hello");