added some edge cases for printf tests

added some edge cases for printf tests
This commit is contained in:
maxvostrikov 2024-09-18 17:22:36 +02:00
parent 7fd2207626
commit f4b4b3cc35
2 changed files with 60 additions and 42 deletions

View File

@ -1,21 +1,31 @@
1 %d: 123
1 %d: -123
1 %d: 0
1 %d: 9223372036854775807
1 %i: 123
1 %u: 123
1 %o: 173
1 %x: 7b
1 %X: 7B
1 %f: 0.000000
1 %f: 123.456000
1 %f: -123.456000
1 %F: 123.456000
1 %e: 1.234560e+02
1 %E: 1.234560E+02
1 %g: 123.456
1 %G: 123.456
1 %a: 0x1.edd2f1a9fbe77p+6
1 %A: 0X1.EDD2F1A9FBE77P+6
1 %s: abc
1 ┌─printf('%%s: %s', '\n\t')─┐
1. │ %s:
└───────────────────────────┘
%s:
%%: %
%.5d: 00123
%.2f: 123.46
%.2e: 1.23e+02
%.2g: 1.2e+02
%.2s: ab

View File

@ -1,39 +1,47 @@
-- Testing integer formats -- Testing integer formats
select printf('%%d: %d', 123) = '%d: 123'; select printf('%%d: %d', 123);
select printf('%%i: %i', 123) = '%i: 123'; select printf('%%d: %d', -123);
select printf('%%u: %u', 123) = '%u: 123'; select printf('%%d: %d', 0);
select printf('%%o: %o', 123) = '%o: 173'; select printf('%%d: %d', 9223372036854775807);
select printf('%%x: %x', 123) = '%x: 7b'; select printf('%%i: %i', 123);
select printf('%%X: %X', 123) = '%X: 7B'; select printf('%%u: %u', 123);
select printf('%%o: %o', 123);
select printf('%%x: %x', 123);
select printf('%%X: %X', 123);
-- Testing floating point formats -- Testing floating point formats
select printf('%%f: %f', 123.456) = '%f: 123.456000'; select printf('%%f: %f', 0.0);
select printf('%%F: %F', 123.456) = '%F: 123.456000'; select printf('%%f: %f', 123.456);
select printf('%%e: %e', 123.456) = '%e: 1.234560e+02'; select printf('%%f: %f', -123.456);
select printf('%%E: %E', 123.456) = '%E: 1.234560E+02'; select printf('%%F: %F', 123.456);
select printf('%%g: %g', 123.456) = '%g: 123.456'; select printf('%%e: %e', 123.456);
select printf('%%G: %G', 123.456) = '%G: 123.456'; select printf('%%E: %E', 123.456);
select printf('%%a: %a', 123.456) = '%a: 0x1.edd2f1a9fbe77p+6'; select printf('%%g: %g', 123.456);
select printf('%%A: %A', 123.456) = '%A: 0X1.EDD2F1A9FBE77P+6'; select printf('%%G: %G', 123.456);
select printf('%%a: %a', 123.456);
select printf('%%A: %A', 123.456);
-- Testing character formats -- Testing character formats
select printf('%%s: %s', 'abc') = '%s: abc'; select printf('%%s: %s', 'abc');
SELECT printf('%%s: %s', '\n\t') FORMAT PrettyCompact;
select printf('%%s: %s', '');
-- Testing the %% specifier -- Testing the %% specifier
select printf('%%%%: %%') = '%%: %'; select printf('%%%%: %%');
-- Testing integer formats with precision -- Testing integer formats with precision
select printf('%%.5d: %.5d', 123) = '%.5d: 00123'; select printf('%%.5d: %.5d', 123);
-- Testing floating point formats with precision -- Testing floating point formats with precision
select printf('%%.2f: %.2f', 123.456) = '%.2f: 123.46'; select printf('%%.2f: %.2f', 123.456);
select printf('%%.2e: %.2e', 123.456) = '%.2e: 1.23e+02'; select printf('%%.2e: %.2e', 123.456);
select printf('%%.2g: %.2g', 123.456) = '%.2g: 1.2e+02'; select printf('%%.2g: %.2g', 123.456);
-- Testing character formats with precision -- Testing character formats with precision
select printf('%%.2s: %.2s', 'abc') = '%.2s: ab'; select printf('%%.2s: %.2s', 'abc');
select printf('%%X: %X', 123.123); -- { serverError BAD_ARGUMENTS } select printf('%%X: %X', 123.123); -- { serverError BAD_ARGUMENTS }
select printf('%%A: %A', 'abc'); -- { serverError BAD_ARGUMENTS } select printf('%%A: %A', 'abc'); -- { serverError BAD_ARGUMENTS }
select printf('%%s: %s', 100); -- { serverError BAD_ARGUMENTS } select printf('%%s: %s', 100); -- { serverError BAD_ARGUMENTS }
select printf('%%n: %n', 100); -- { serverError BAD_ARGUMENTS } select printf('%%n: %n', 100); -- { serverError BAD_ARGUMENTS }
select printf('%%f: %f', 0); -- { serverError BAD_ARGUMENTS }