diff options
| author | David Faulkner <[email protected]> | 2026-08-07 23:40:47 -0500 |
|---|---|---|
| committer | David Faulkner <[email protected]> | 2026-08-07 23:40:47 -0500 |
| commit | b3e9e62599532050fc776c5e8f076915b56c2235 (patch) | |
| tree | af252346106a61b18cc6fc6fdbd32e962d096f1c /test-strfrom.c | |
Import official C23 code examples for Modern C (Jens Gustedt, 2024)HEADupstream-importmain
- Add official C source files, Makefile, c23-fallback.h, and LICENSE
- Update README.md with study mirror notice
Diffstat (limited to 'test-strfrom.c')
| -rw-r--r-- | test-strfrom.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test-strfrom.c b/test-strfrom.c new file mode 100644 index 0000000..7c5316b --- /dev/null +++ b/test-strfrom.c @@ -0,0 +1,26 @@ +#include <stdlib.h> +#include <stdio.h> + +#define testIt(FUNC, F, V) \ + do { \ + char buf[256]; \ + int ret = FUNC(buf, 256, (F), (V)); \ + printf("%d: %s\n", ret, buf); \ + } while (0) + +int main(void) { + testIt(strfromd, "%g", 1.0/7); + testIt(strfromd, "%.6766g", 1.0/7); + testIt(strfromd, "%.0000000000000000000000000000000000000000000006766g", 1.0/7); + testIt(strfroml, "%g", 1.0L/7); + testIt(strfroml, "%.6766g", 1.0L/7); + testIt(strfroml, "%.0000000000000000000000000000000000000000000006766g", 1.0L/7); + testIt(strfroml, "%.547996766g", 1.0L/7); + testIt(strfromd, "%a", 1.0/7); + testIt(strfromd, "%.6766a", 1.0/7); + testIt(strfromd, "%.0000000000000000000000000000000000000000000006766a", 1.0/7); + testIt(strfroml, "%a", 1.0L/7); + testIt(strfroml, "%.6766a", 1.0L/7); + testIt(strfroml, "%.0000000000000000000000000000000000000000000006766a", 1.0L/7); + testIt(strfroml, "%.547996766a", 1.0L/7); +} |
