Lines Matching refs:rc

239 #define TEST_PRF2(rc, _fmt, ...) do { \  argument
266 *rc = prf(sp_buf, _fmt, __VA_ARGS__); \
269 #define TEST_PRF(rc, _fmt, ...) \ argument
270 TEST_PRF2(rc, WRAP_FMT(_fmt), PASS_ARG(__VA_ARGS__))
273 #define TEST_PRF_LONG_DOUBLE(rc, _fmt, ...) \ argument
274 TEST_PRF(rc, _fmt, __VA_ARGS__)
277 #define TEST_PRF_LONG_DOUBLE(rc, _fmt, ...) \ argument
278 *rc = prf(NULL, WRAP_FMT(_fmt), PASS_ARG(__VA_ARGS__))
319 int rc; in prf_check() local
322 rc = match_pfx(&str); in prf_check()
323 if (rc != 0) { in prf_check()
324 return prf_failed(&ctx, sp, "pfx mismatch %d\n", rc); in prf_check()
328 rc = match_str(&str, expected, strlen(expected)); in prf_check()
329 if (rc != 0) { in prf_check()
330 return prf_failed(&ctx, sp, "str mismatch %d\n", rc); in prf_check()
334 rc = match_sfx(&str); in prf_check()
335 if (rc != 0) { in prf_check()
336 return prf_failed(&ctx, sp, "sfx mismatch, %d\n", rc); in prf_check()
339 rc = (*str != 0); in prf_check()
340 if (rc != 0) { in prf_check()
347 return prf_failed(&ctx, str, "nano rv %d != 0\n", rc); in prf_check()
367 int rc; in ZTEST() local
369 TEST_PRF(&rc, "/%%/%c/", 'a'); in ZTEST()
371 PRF_CHECK("/%/a/", rc); in ZTEST()
376 int rc; in ZTEST() local
378 TEST_PRF(&rc, "%c", 'a'); in ZTEST()
379 PRF_CHECK("a", rc); in ZTEST()
381 rc = prf(NULL, "/%256c/", 'a'); in ZTEST()
386 zassert_equal(rc, 258, "len %d", rc); in ZTEST()
402 TEST_PRF(&rc, "%lc", (wint_t)'a'); in ZTEST()
404 PRF_CHECK("a", rc); in ZTEST()
406 PRF_CHECK("%lc", rc); in ZTEST()
414 int rc; in ZTEST() local
416 TEST_PRF(&rc, "/%s/", s); in ZTEST()
417 PRF_CHECK("/123/", rc); in ZTEST()
419 TEST_PRF(&rc, "/%6s/%-6s/%2s/", s, s, s); in ZTEST()
420 PRF_CHECK("/ 123/123 /123/", rc); in ZTEST()
422 TEST_PRF(&rc, "/%.6s/%.2s/%.s/", s, s, s); in ZTEST()
423 PRF_CHECK("/123/12//", rc); in ZTEST()
430 TEST_PRF(&rc, "%ls", ws); in ZTEST()
432 PRF_CHECK("abc", rc); in ZTEST()
434 PRF_CHECK("%ls", rc); in ZTEST()
440 int rc; in ZTEST() local
444 rc = rawprf("%c", 'a'); in ZTEST()
445 zassert_equal(rc, 1); in ZTEST()
459 int rc; in ZTEST() local
461 TEST_PRF(&rc, "%d/%d", min, max); in ZTEST()
462 PRF_CHECK("-1234567890/1876543210", rc); in ZTEST()
464 TEST_PRF(&rc, "%u/%u", min, max); in ZTEST()
465 PRF_CHECK("3060399406/1876543210", rc); in ZTEST()
468 TEST_PRF(&rc, "%hd/%hd", (short) min, (short) max); in ZTEST()
469 PRF_CHECK("-722/-14614", rc); in ZTEST()
471 TEST_PRF(&rc, "%hhd/%hhd", (char) min, (char) max); in ZTEST()
472 PRF_CHECK("46/-22", rc); in ZTEST()
475 TEST_PRF(&rc, "%ld/%ld/%lu/", (long)min, (long)max, 4000000000UL); in ZTEST()
479 PRF_CHECK("-1234567890/1876543210/4000000000/", rc); in ZTEST()
481 PRF_CHECK("%ld/%ld/%lu/", rc); in ZTEST()
484 TEST_PRF(&rc, "/%lld/%lld/%lld/%llu/", svll, -svll, svll2, uvll); in ZTEST()
486 PRF_CHECK("/34621422135410688/-34621422135410688/-2/4000000000/", rc); in ZTEST()
488 PRF_CHECK("/%lld/%lld/%lld/%llu/", rc); in ZTEST()
490 PRF_CHECK("/ERR/ERR/-2/4000000000/", rc); in ZTEST()
495 TEST_PRF(&rc, "%lld/%lld", (long long)min, (long long)max); in ZTEST()
497 PRF_CHECK("-1234567890/1876543210", rc); in ZTEST()
499 PRF_CHECK("-1234567890/1876543210", rc); in ZTEST()
501 PRF_CHECK("%lld/%lld", rc); in ZTEST()
509 TEST_PRF(&rc, "%jd/%jd", (intmax_t)min, (intmax_t)max); in ZTEST()
511 PRF_CHECK("-1234567890/1876543210", rc); in ZTEST()
513 PRF_CHECK("%jd/%jd", rc); in ZTEST()
516 TEST_PRF(&rc, "%zd/%td/%td", (size_t)min, (ptrdiff_t)min, in ZTEST()
520 PRF_CHECK("-1234567890/-1234567890/1876543210", rc); in ZTEST()
522 PRF_CHECK("%zd/%td/%td", rc); in ZTEST()
530 rc = rawprf("/%Ld/", max); in ZTEST()
531 zassert_equal(rc, 5, "len %d", rc); in ZTEST()
532 zassert_equal(strncmp("/%Ld/", buf, rc), 0); in ZTEST()
538 int rc; in ZTEST() local
541 TEST_PRF(&rc, "/%d/%-d/%+d/% d/", in ZTEST()
543 PRF_CHECK("/123/123/+123/ 123/", rc); in ZTEST()
546 TEST_PRF(&rc, "/%1d/%4d/%-4d/%04d/%15d/%-15d/", in ZTEST()
549 " 123/123 /", rc); in ZTEST()
552 TEST_PRF(&rc, "/%.6d/%6.4d/", sv, sv); in ZTEST()
553 PRF_CHECK("/000123/ 0123/", rc); in ZTEST()
557 TEST_PRF(&rc, "/%d/%-d/%+d/% d/", in ZTEST()
559 PRF_CHECK("/-123/-123/-123/-123/", rc); in ZTEST()
561 TEST_PRF(&rc, "/%1d/%6d/%-6d/%06d/%13d/%-13d/", in ZTEST()
564 " -123/-123 /", rc); in ZTEST()
566 TEST_PRF(&rc, "/%.6d/%6.4d/", sv, sv); in ZTEST()
567 PRF_CHECK("/-000123/ -0123/", rc); in ZTEST()
575 rc = rawprf("/%#d/% +d/%-04d/%06.4d/", sv, sv, sv, sv); in ZTEST()
576 zassert_equal(rc, 22, "rc %d", rc); in ZTEST()
578 buf, rc), 0, NULL); in ZTEST()
585 int rc; in ZTEST() local
587 TEST_PRF(&rc, "%x/%X", min, max); in ZTEST()
588 PRF_CHECK("4c3c2c1c/4D3D2D1D", rc); in ZTEST()
590 TEST_PRF(&rc, "%lx/%lX", (unsigned long)min, (unsigned long)max); in ZTEST()
594 PRF_CHECK("4c3c2c1c/4D3D2D1D", rc); in ZTEST()
596 PRF_CHECK("%lx/%lX", rc); in ZTEST()
604 TEST_PRF(&rc, "%hx/%hX", (short) min, (short) max); in ZTEST()
605 PRF_CHECK("2c1c/2D1D", rc); in ZTEST()
607 TEST_PRF(&rc, "%hhx/%hhX", (char) min, (char) max); in ZTEST()
608 PRF_CHECK("1c/1D", rc); in ZTEST()
611 TEST_PRF(&rc, "%llx/%llX", (unsigned long long)min, in ZTEST()
613 PRF_CHECK("4c3c2c1c/4D3D2D1D", rc); in ZTEST()
615 TEST_PRF(&rc, "%jx/%jX", (uintmax_t)min, (uintmax_t)max); in ZTEST()
616 PRF_CHECK("4c3c2c1c/4D3D2D1D", rc); in ZTEST()
619 TEST_PRF(&rc, "%zx/%zX", (size_t)min, (size_t)max); in ZTEST()
622 PRF_CHECK("4c3c2c1c/4D3D2D1D", rc); in ZTEST()
624 PRF_CHECK("%zx/%zX", rc); in ZTEST()
627 TEST_PRF(&rc, "%tx/%tX", (ptrdiff_t)min, (ptrdiff_t)max); in ZTEST()
630 PRF_CHECK("4c3c2c1c/4D3D2D1D", rc); in ZTEST()
632 PRF_CHECK("%tx/%tX", rc); in ZTEST()
640 TEST_PRF(&rc, "%llx/%llX", (unsigned long long)min, in ZTEST()
642 PRF_CHECK("8c7c6c5c4c3c2c1c/8D7D6D5D4D3D2D1D", rc); in ZTEST()
649 int rc; in ZTEST() local
654 TEST_PRF(&rc, "/%x/%-x/%#x/", in ZTEST()
656 PRF_CHECK("/123/123/0x123/", rc); in ZTEST()
659 TEST_PRF(&rc, "/%1x/%4x/%-4x/%04x/%#15x/%-15x/", in ZTEST()
662 " 0x123/123 /", rc); in ZTEST()
669 rc = rawprf("/%+x/% x/", sv, sv); in ZTEST()
670 zassert_equal(rc, 9, "rc %d", rc); in ZTEST()
671 zassert_equal(strncmp("/123/123/", buf, rc), 0); in ZTEST()
677 int rc; in ZTEST() local
684 TEST_PRF(&rc, "%o", v); in ZTEST()
685 PRF_CHECK("1234567", rc); in ZTEST()
686 TEST_PRF(&rc, "%#o", v); in ZTEST()
687 PRF_CHECK("01234567", rc); in ZTEST()
698 int rc; in ZTEST() local
700 TEST_PRF(&rc, "/%f/%F/", dv, dv); in ZTEST()
701 PRF_CHECK("/1234.567000/1234.567000/", rc); in ZTEST()
702 TEST_PRF(&rc, "%g", dv); in ZTEST()
703 PRF_CHECK("1234.57", rc); in ZTEST()
704 TEST_PRF(&rc, "%e", dv); in ZTEST()
705 PRF_CHECK("1.234567e+03", rc); in ZTEST()
706 TEST_PRF(&rc, "%E", dv); in ZTEST()
707 PRF_CHECK("1.234567E+03", rc); in ZTEST()
708 TEST_PRF(&rc, "%a", dv); in ZTEST()
710 PRF_CHECK("0x1.34a449ba5e354p+10", rc); in ZTEST()
712 PRF_CHECK("%a", rc); in ZTEST()
716 TEST_PRF(&rc, "%.2f", dv); in ZTEST()
717 PRF_CHECK("1000.00", rc); in ZTEST()
720 TEST_PRF(&rc, "%.0f", dv); in ZTEST()
721 PRF_CHECK("100000000000000000000", rc); in ZTEST()
722 TEST_PRF(&rc, "%.20e", dv); in ZTEST()
723 PRF_CHECK("1.00000000000000000000e+20", rc); in ZTEST()
726 TEST_PRF(&rc, "%.3e", dv); in ZTEST()
727 PRF_CHECK("1.000e-03", rc); in ZTEST()
730 TEST_PRF(&rc, "%g", dv); in ZTEST()
731 PRF_CHECK("0.001", rc); in ZTEST()
734 TEST_PRF(&rc, "%g", dv); in ZTEST()
735 PRF_CHECK("1.23457e+06", rc); in ZTEST()
739 TEST_PRF(&rc, "/%a/%.4a/%.20a/", dv, dv, dv); in ZTEST()
741 "0x1.00000000000000000000p+40/", rc); in ZTEST()
744 TEST_PRF(&rc, "%a", dv); in ZTEST()
745 PRF_CHECK("0x1.01p+40", rc); in ZTEST()
749 TEST_PRF(&rc, "%f.f %F.F %e.e %E.E %g.g %G.g %a.a %A.A", in ZTEST()
753 "inf.g INF.g inf.a INF.A", rc); in ZTEST()
756 "inf.g INF.g %a.a %A.A", rc); in ZTEST()
760 TEST_PRF(&rc, "%f.f %F.F %e.e %E.E %g.g %G.g %a.a %A.A", in ZTEST()
764 "-inf.g -INF.g -inf.a -INF.A", rc); in ZTEST()
767 "-inf.g -INF.g %a.a %A.A", rc); in ZTEST()
771 TEST_PRF(&rc, "%f.f %F.F %e.e %E.E %g.g %G.g %a.a %A.A", in ZTEST()
775 "nan.g NAN.g nan.a NAN.A", rc); in ZTEST()
778 "nan.g NAN.g %a.a %A.A", rc); in ZTEST()
782 TEST_PRF(&rc, "%a %e", dv, dv); in ZTEST()
784 PRF_CHECK("0x1p-1022 2.225074e-308", rc); in ZTEST()
786 PRF_CHECK("%a 2.225074e-308", rc); in ZTEST()
790 TEST_PRF(&rc, "%a %e", dv, dv); in ZTEST()
792 PRF_CHECK("0x0.4p-1022 5.562685e-309", rc); in ZTEST()
794 PRF_CHECK("%a 5.562685e-309", rc); in ZTEST()
803 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
804 PRF_CHECK("0.125", rc); in ZTEST()
807 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
808 PRF_CHECK("0.0625", rc); in ZTEST()
811 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
812 PRF_CHECK("0.09375", rc); in ZTEST()
815 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
816 PRF_CHECK("0.109375", rc); in ZTEST()
819 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
820 PRF_CHECK("0.01249999999708962", rc); in ZTEST()
823 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
824 PRF_CHECK("0.006250000005820765", rc); in ZTEST()
827 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
828 PRF_CHECK("1", rc); in ZTEST()
831 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
832 PRF_CHECK("4.450147717014402e-308", rc); in ZTEST()
835 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
836 PRF_CHECK("4.450147717014402e-308", rc); in ZTEST()
839 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
840 PRF_CHECK("4.450147717014401e-308", rc); in ZTEST()
843 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
844 PRF_CHECK("2.225073858507202e-308", rc); in ZTEST()
847 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
848 PRF_CHECK("2.225073858507201e-308", rc); in ZTEST()
851 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
852 PRF_CHECK("2.225073858507201e-308", rc); in ZTEST()
855 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
856 PRF_CHECK("4.940656458412465e-324", rc); in ZTEST()
859 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
860 PRF_CHECK("2e-307", rc); in ZTEST()
863 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
864 PRF_CHECK("1.797693134862316e+308", rc); in ZTEST()
867 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
868 PRF_CHECK("1.797693134862316e+308", rc); in ZTEST()
871 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
872 PRF_CHECK("1.797693134862315e+308", rc); in ZTEST()
875 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
876 PRF_CHECK("8.988465674311582e+307", rc); in ZTEST()
879 TEST_PRF(&rc, "%.16g", dv); in ZTEST()
880 PRF_CHECK("8.98846567431158e+307", rc); in ZTEST()
891 int rc; in ZTEST() local
893 TEST_PRF(&rc, "/%g/", dv); in ZTEST()
895 PRF_CHECK("/1.2345/", rc); in ZTEST()
897 PRF_CHECK("/%g/", rc); in ZTEST()
900 TEST_PRF(&rc, "/%lg/", dv); in ZTEST()
902 PRF_CHECK("/1.2345/", rc); in ZTEST()
904 PRF_CHECK("/%lg/", rc); in ZTEST()
907 TEST_PRF_LONG_DOUBLE(&rc, "/%Lg/", (long double)dv); in ZTEST()
909 PRF_CHECK("/1.2345/", rc); in ZTEST()
911 PRF_CHECK("/%Lg/", rc); in ZTEST()
919 rc = rawprf("/%hf/", dv); in ZTEST()
920 zassert_equal(rc, 5, "len %d", rc); in ZTEST()
921 zassert_equal(strncmp("/%hf/", buf, rc), 0); in ZTEST()
932 int rc; in ZTEST() local
934 TEST_PRF(&rc, "/%g/% g/%+g/", dv, dv, dv); in ZTEST()
935 PRF_CHECK("/1.23/ 1.23/+1.23/", rc); in ZTEST()
938 TEST_PRF(&rc, "/%a/%.1a/%.2a/", dv, dv, dv); in ZTEST()
940 "0x1.4p+0/0x1.3bp+0/", rc); in ZTEST()
944 TEST_PRF(&rc, "/%g/% g/%+g/", dv, dv, dv); in ZTEST()
945 PRF_CHECK("/-1.23/-1.23/-1.23/", rc); in ZTEST()
948 TEST_PRF(&rc, "/%g/%#g/%.0f/%#.0f/", dv, dv, dv, dv); in ZTEST()
949 PRF_CHECK("/23/23.0000/23/23./", rc); in ZTEST()
951 rc = prf(NULL, "% .380f", 0x1p-400); in ZTEST()
952 zassert_equal(rc, 383); in ZTEST()
959 int rc; in ZTEST() local
961 TEST_PRF(&rc, "/%3c/%-3c/", 'a', 'a'); in ZTEST()
962 PRF_CHECK("/ a/a /", rc); in ZTEST()
964 TEST_PRF(&rc, "/%*c/%*c/", 3, 'a', -3, 'a'); in ZTEST()
965 PRF_CHECK("/ a/a /", rc); in ZTEST()
970 int rc; in ZTEST() local
972 TEST_PRF(&rc, "/%.*x/%10.*x/", in ZTEST()
974 PRF_CHECK("/00012/ 00012/", rc); in ZTEST()
984 TEST_PRF(&rc, "/%.3g/%.5g/%.8g/%g/", in ZTEST()
986 PRF_CHECK("/1.23/1.2346/1.2345678/1.23457/", rc); in ZTEST()
988 TEST_PRF(&rc, "/%.*g/%.*g/%.*g/%.*g/", in ZTEST()
993 PRF_CHECK("/1.23/1.2346/1.2345678/1.23457/", rc); in ZTEST()
1016 int rc; in ZTEST() local
1018 rc = prf(NULL, "12345%n", &l); in ZTEST()
1019 zassert_equal(l, rc, "%d != %d", l, rc); in ZTEST()
1020 zassert_equal(rc, 5); in ZTEST()
1023 rc = prf(NULL, "12345%hn", &l_h); in ZTEST()
1024 zassert_equal(l_h, rc); in ZTEST()
1026 rc = prf(NULL, "12345%hhn", &l_hh); in ZTEST()
1027 zassert_equal(l_hh, rc); in ZTEST()
1029 rc = prf(NULL, "12345%ln", &l_l); in ZTEST()
1030 zassert_equal(l_l, rc); in ZTEST()
1032 rc = prf(NULL, "12345%lln", &l_ll); in ZTEST()
1033 zassert_equal(l_ll, rc); in ZTEST()
1035 rc = prf(NULL, "12345%jn", &l_j); in ZTEST()
1036 zassert_equal(l_j, rc); in ZTEST()
1038 rc = prf(NULL, "12345%zn", &l_z); in ZTEST()
1039 zassert_equal(l_z, rc); in ZTEST()
1041 rc = prf(NULL, "12345%tn", &l_t); in ZTEST()
1042 zassert_equal(l_t, rc); in ZTEST()
1057 int rc; in ZTEST() local
1059 TEST_PRF(&rc, "%p", ptr); in ZTEST()
1060 PRF_CHECK("0xcafe21", rc); in ZTEST()
1061 TEST_PRF(&rc, "%p", NULL); in ZTEST()
1062 PRF_CHECK("(nil)", rc); in ZTEST()
1065 rc = rawprf("/%12p/", ptr); in ZTEST()
1066 zassert_equal(rc, 14); in ZTEST()
1067 zassert_equal(strncmp("/ 0xcafe21/", buf, rc), 0); in ZTEST()
1070 rc = rawprf("/%12p/", NULL); in ZTEST()
1071 zassert_equal(rc, 14); in ZTEST()
1072 zassert_equal(strncmp("/ (nil)/", buf, rc), 0); in ZTEST()
1075 rc = rawprf("/%-12p/", ptr); in ZTEST()
1076 zassert_equal(rc, 14); in ZTEST()
1077 zassert_equal(strncmp("/0xcafe21 /", buf, rc), 0); in ZTEST()
1080 rc = rawprf("/%-12p/", NULL); in ZTEST()
1081 zassert_equal(rc, 14); in ZTEST()
1082 zassert_equal(strncmp("/(nil) /", buf, rc), 0); in ZTEST()
1085 rc = rawprf("/%.8p/", ptr); in ZTEST()
1086 zassert_equal(rc, 12); in ZTEST()
1087 zassert_equal(strncmp("/0x00cafe21/", buf, rc), 0); in ZTEST()
1116 int rc; in ZTEST() local
1120 rc = snprintfcb(lbuf, len, "%06d", 1); in ZTEST()
1121 zassert_equal(rc, 6); in ZTEST()
1122 zassert_equal(strncmp("000001", lbuf, rc), 0); in ZTEST()
1125 rc = snprintfcb(lbuf, len, "%07d", 1); in ZTEST()
1126 zassert_equal(rc, 7); in ZTEST()
1127 zassert_equal(strncmp("000000", lbuf, rc), 0); in ZTEST()
1130 rc = snprintfcb(lbuf, len, "%020d", 1); in ZTEST()
1131 zassert_equal(rc, 20, "rc %d", rc); in ZTEST()
1133 zassert_equal(strncmp("000000", lbuf, rc), 0); in ZTEST()
1135 rc = cbprintf(out_counter, &count, "%020d", 1); in ZTEST()
1136 zassert_equal(rc, 20, "rc %d", rc); in ZTEST()
1140 rc = cbprintf(out_e42, NULL, "%020d", 1); in ZTEST()
1141 zassert_equal(rc, -42, "rc %d", rc); in ZTEST()
1152 int rc; in ZTEST() local
1156 rc = cbprintf_package(NULL, PKG_ALIGN_OFFSET, PACKAGE_FLAGS, fmt, 3); in ZTEST()
1157 zassert_true(rc > sizeof(int)); in ZTEST()
1160 size_t len = rc; in ZTEST()
1167 rc = cbprintf_package(&buf[PKG_ALIGN_OFFSET], len, PACKAGE_FLAGS, fmt, 3); in ZTEST()
1168 zassert_equal(rc, len); in ZTEST()
1172 rc = cbprintf_package(&buf[PKG_ALIGN_OFFSET], len, PACKAGE_FLAGS, fmt, 3); in ZTEST()
1173 zassert_equal(rc, -ENOSPC); in ZTEST()
1326 int rc; in ZTEST() local
1333 rc = cbpprintf(out, &outbuf, NULL); in ZTEST()
1334 zassert_equal(rc, -EINVAL); in ZTEST()