From 34a934c4e1a302c132ed391f9e626c0dad5ba599 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sun, 25 Dec 2022 13:12:53 +0400 Subject: [PATCH] Remove Python --- .cirrus.yml | 3 +- .github/workflows/main.yml | 8 +- .openbsd.yml | 6 - README.md | 1 - configure.ac | 35 -- fixtures/cmdline.yml | 241 -------------- fixtures/printf.yml | 131 -------- fixtures/printf_fmt.yml | 340 ------------------- fixtures/printf_orig.yml | 667 ------------------------------------- tests/.gitignore | 6 - tests/Makefile.am | 69 ---- tests/cmdline_gen.jinja | 46 --- tests/cmdline_gen.py | 49 --- tests/printf_fmt_gen.jinja | 36 -- tests/printf_fmt_gen.py | 65 ---- tests/printf_gen.jinja | 76 ----- tests/printf_gen.py | 88 ----- 17 files changed, 5 insertions(+), 1862 deletions(-) delete mode 100644 fixtures/cmdline.yml delete mode 100644 fixtures/printf.yml delete mode 100644 fixtures/printf_fmt.yml delete mode 100644 fixtures/printf_orig.yml delete mode 100644 tests/cmdline_gen.jinja delete mode 100644 tests/cmdline_gen.py delete mode 100644 tests/printf_fmt_gen.jinja delete mode 100644 tests/printf_fmt_gen.py delete mode 100644 tests/printf_gen.jinja delete mode 100644 tests/printf_gen.py diff --git a/.cirrus.yml b/.cirrus.yml index 9ef966f..39cd331 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -8,8 +8,7 @@ main_freebsd_task: name: Main (FreeBSD) only_if: $CIRRUS_BRANCH == 'master' || $CIRRUS_BASE_BRANCH == 'master' dependencies_script: - - pkg install --yes autoconf automake cppcheck libtool libyaml py39-pip py39-wheel python3 - - pip install --user Jinja2 PyYAML + - pkg install --yes autoconf automake cppcheck libtool main_build_script: - ./autogen.sh - ./configure --enable-checks-all CFLAGS='-O3' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b294bfa..16e8915 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,7 +34,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure ${{matrix.assert}} --enable-checks --enable-checks-python CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}' + run: ./configure ${{matrix.assert}} --enable-checks CC='${{matrix.cc}}' CFLAGS='${{matrix.opt}}' - name: make run: make - name: check @@ -76,7 +76,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure --host='${{matrix.cross.arch}}-unknown-elf' --enable-checks --enable-checks-python CC='${{matrix.cross.cprefix}}gcc' + run: ./configure --host='${{matrix.cross.arch}}-unknown-elf' --enable-checks CC='${{matrix.cross.cprefix}}gcc' - name: make run: make - name: check @@ -100,7 +100,7 @@ jobs: - name: autogen run: ./autogen.sh - name: configure - run: ./configure --enable-checks --enable-checks-python --without-${{matrix.packages.without}} ${{matrix.packages.dependencies}} + run: ./configure --enable-checks --without-${{matrix.packages.without}} ${{matrix.packages.dependencies}} - name: make run: make - name: check @@ -139,7 +139,7 @@ jobs: - name: extract run: tar -xzf "libkernaux-$(cat VERSION).tar.gz" - name: configure - run: cd "libkernaux-$(cat VERSION)" && ./configure --enable-checks --enable-checks-python + run: cd "libkernaux-$(cat VERSION)" && ./configure --enable-checks - name: make run: cd "libkernaux-$(cat VERSION)" && make - name: check diff --git a/.openbsd.yml b/.openbsd.yml index e263cd6..8442820 100644 --- a/.openbsd.yml +++ b/.openbsd.yml @@ -9,11 +9,7 @@ packages: - autoconf-2.71 - automake-1.16.5 - cppcheck - - libyaml - m4 - - py3-pip - - py3-wheel - - python3 - wget environment: AUTOCONF_VERSION: '2.71' @@ -26,8 +22,6 @@ tasks: ./configure make doas make install - - dependencies: | - pip3 install --user Jinja2 PyYAML - build: | cd libkernaux ./autogen.sh diff --git a/README.md b/README.md index c41949e..3976870 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,6 @@ stable options. * `--enable-checks` - enable usual tests and examples * `--enable-checks-all` - enable all checks * `--enable-checks-cppcheck` - enable cppcheck -* `--enable-checks-python` - enable tests that require Python 3 with YAML and Jinja2 * `--enable-pkg-config[=PATH]` - install pkg-config files [PATH='${libdir}/pkgconfig'] diff --git a/configure.ac b/configure.ac index e59ff0e..fc25f55 100644 --- a/configure.ac +++ b/configure.ac @@ -57,7 +57,6 @@ AC_ARG_ENABLE([freestanding], AS_HELP_STRING([--enable-freestanding], [bui AC_ARG_ENABLE([checks], AS_HELP_STRING([--enable-checks], [enable usual tests and examples])) AC_ARG_ENABLE([checks-all], AS_HELP_STRING([--enable-checks-all], [enable all checks])) AC_ARG_ENABLE([checks-cppcheck], AS_HELP_STRING([--enable-checks-cppcheck], [enable cppcheck])) -AC_ARG_ENABLE([checks-python], AS_HELP_STRING([--enable-checks-python], [enable tests that require Python 3 with YAML and Jinja2])) AC_ARG_ENABLE([split-libc], AS_HELP_STRING([--enable-split-libc], [split off libc])) dnl Features (with parameter) @@ -95,7 +94,6 @@ AC_DEFUN([do_enable_checks_all], [ if test -z "$enable_checks"; then enable_checks=yes; fi if test -z "$enable_checks_cppcheck"; then enable_checks_cppcheck=yes; fi -if test -z "$enable_checks_python"; then enable_checks_python=yes; fi ]) AS_IF([test "$enable_checks_all" = yes], do_enable_checks_all) @@ -143,7 +141,6 @@ AS_IF([test "$enable_freestanding" = yes], [enable_freestanding=yes], [ena AS_IF([test "$enable_checks" = yes], [enable_checks=yes], [enable_checks=no]) AS_IF([test "$enable_checks_all" = yes], [enable_checks_all=yes], [enable_checks_all=no]) AS_IF([test "$enable_checks_cppcheck" = yes], [enable_checks_cppcheck=yes], [enable_checks_cppcheck=no]) -AS_IF([test "$enable_checks_python" = yes], [enable_checks_python=yes], [enable_checks_python=no]) AS_IF([test "$enable_split_libc" = yes], [enable_split_libc=yes], [enable_split_libc=no]) dnl Features (with parameter) @@ -208,7 +205,6 @@ dnl Features (disabled by default) AM_CONDITIONAL([ENABLE_FREESTANDING], [test "$enable_freestanding" = yes]) AM_CONDITIONAL([ENABLE_CHECKS], [test "$enable_checks" = yes]) AM_CONDITIONAL([ENABLE_CHECKS_CPPCHECK], [test "$enable_checks_cppcheck" = yes]) -AM_CONDITIONAL([ENABLE_CHECKS_PYTHON], [test "$enable_checks_python" = yes]) AM_CONDITIONAL([ENABLE_SPLIT_LIBC], [test "$enable_split_libc" = yes]) dnl Features (with parameter) @@ -261,7 +257,6 @@ dnl Features (disabled by default) AS_IF([test "$enable_freestanding" = yes], [AC_DEFINE([ENABLE_FREESTANDING], [1], [build for freestanding environment])]) AS_IF([test "$enable_checks" = yes], [AC_DEFINE([ENABLE_CHECKS], [1], [enabled usual tests and examples])]) AS_IF([test "$enable_checks_cppcheck" = yes], [AC_DEFINE([ENABLE_CHECKS_CPPCHECK], [1], [enabled cppcheck])]) -AS_IF([test "$enable_checks_python" = yes], [AC_DEFINE([ENABLE_CHECKS_PYTHON], [1], [enabled tests that require Python 3 with YAML and Jinja2])]) AS_IF([test "$enable_split_libc" = yes], [AC_DEFINE([ENABLE_SPLIT_LIBC], [1], [split off libc])]) dnl Packages (enabled by default) @@ -345,40 +340,10 @@ AS_IF([test "$enable_checks" = yes], [AC_CHECK_HEADERS([assert.h setjmp.h stdio.h stdlib.h string.h],, [AC_MSG_ERROR([the headers are required])])]) -AM_PATH_PYTHON([3.8],, [:]) -AS_IF([test "$enable_checks_python" = yes -a "$enable_checks" = yes -a "$PYTHON" = ':'], - [AC_MSG_ERROR([Python is required])]) - AC_PATH_PROGS([CPPCHECK], [cppcheck], [:]) AS_IF([test "$enable_checks_cppcheck" = yes -a "$CPPCHECK" = ':'], [AC_MSG_ERROR([cppcheck is required])]) -AC_CACHE_CHECK([for Python YAML], - [libkernaux_cv_shell_pythonyaml_exists], - [libkernaux_cv_shell_pythonyaml_exists=no - PYTHON_YAML=no - if test "$PYTHON" != ':'; then - if test "$($PYTHON -c 'import yaml; print(yaml.__package__)')" = 'yaml'; then - libkernaux_cv_shell_pythonyaml_exists=yes - PYTHON_YAML=yes - fi - fi]) -AS_IF([test "$enable_checks_python" = yes -a "$enable_checks" = yes -a "$PYTHON_YAML" != 'yes'], - [AC_MSG_ERROR([Python YAML is required])]) - -AC_CACHE_CHECK([for Python Jinja 2], - [libkernaux_cv_shell_pythonjinja2_exists], - [libkernaux_cv_shell_pythonjinja2_exists=no - PYTHON_JINJA2=no - if test "$PYTHON" != ':'; then - if test "$($PYTHON -c 'import jinja2; print(jinja2.__package__)')" = 'jinja2'; then - libkernaux_cv_shell_pythonjinja2_exists=yes - PYTHON_JINJA2=yes - fi - fi]) -AS_IF([test "$enable_checks_python" = yes -a "$enable_checks" = yes -a "$PYTHON_JINJA2" != 'yes'], - [AC_MSG_ERROR([Python Jinja 2 is required])]) - ###################### diff --git a/fixtures/cmdline.yml b/fixtures/cmdline.yml deleted file mode 100644 index 1ebef83..0000000 --- a/fixtures/cmdline.yml +++ /dev/null @@ -1,241 +0,0 @@ -# TODO: move here test cases from tests/test_cmdline.c - -- cmdline: '' - result: [] -- cmdline: ' ' - result: [] -- cmdline: 'foo' - result: ['foo'] -- cmdline: 'foo bar' - result: ['foo', 'bar'] -- cmdline: 'foo bar ' - result: ['foo', 'bar'] -- cmdline: ' foo bar ' - result: ['foo', 'bar'] -- cmdline: 'foo bar' - result: ['foo', 'bar'] -- cmdline: ' foo bar' - result: ['foo', 'bar'] -- cmdline: 'foo bar ' - result: ['foo', 'bar'] -- cmdline: ' foo bar ' - result: ['foo', 'bar'] -- cmdline: 'foo bar car' - result: ['foo', 'bar', 'car'] - -- cmdline: '\"\"' - result: [''] -- cmdline: '\"\" \"\"' - result: ['', ''] -- cmdline: '\"\" \"\" \"\"' - result: ['', '', ''] -- cmdline: '\"foo\"' - result: ['foo'] -- cmdline: '\"foo\" \"bar\"' - result: ['foo', 'bar'] -- cmdline: ' \"foo\" \"bar\"' - result: ['foo', 'bar'] -- cmdline: '\"foo\" \"bar\" ' - result: ['foo', 'bar'] -- cmdline: ' \"foo\" \"bar\" ' - result: ['foo', 'bar'] -- cmdline: '\"foo\" \"bar\"' - result: ['foo', 'bar'] -- cmdline: '\"foo\" \"bar\" ' - result: ['foo', 'bar'] -- cmdline: ' \"foo\" \"bar\"' - result: ['foo', 'bar'] -- cmdline: ' \"foo\" \"bar\" ' - result: ['foo', 'bar'] -- cmdline: '\"foo\" \"bar\" \"car\"' - result: ['foo', 'bar', 'car'] - -- cmdline: 'foo bar car' - arg_count_max: 3 - result: ['foo', 'bar', 'car'] -- cmdline: 'foo bar car' - buffer_size: 12 - result: ['foo', 'bar', 'car'] -- cmdline: 'foo bar car' - arg_count_max: 3 - buffer_size: 12 - result: ['foo', 'bar', 'car'] - -- cmdline: 'foo bar car' - arg_count_max: 2 - error: 'too many args' -- cmdline: 'foo bar car' - buffer_size: 11 - error: 'EOF or buffer overflow' -- cmdline: 'foo bar car' - arg_count_max: 2 - buffer_size: 11 - error: 'too many args' - -- cmdline: '\"foo\" \"bar\" \"car\"' - arg_count_max: 3 - result: ['foo', 'bar', 'car'] -- cmdline: '\"foo\" \"bar\" \"car\"' - buffer_size: 12 - result: ['foo', 'bar', 'car'] -- cmdline: '\"foo\" \"bar\" \"car\"' - arg_count_max: 3 - buffer_size: 12 - result: ['foo', 'bar', 'car'] - -- cmdline: '\"foo\" \"bar\" \"car\"' - arg_count_max: 2 - error: 'too many args' -- cmdline: '\"foo\" \"bar\" \"car\"' - buffer_size: 11 - error: 'EOF or buffer overflow' -- cmdline: '\"foo\" \"bar\" \"car\"' - arg_count_max: 2 - buffer_size: 11 - error: 'too many args' - -- cmdline: '\\ ' - result: [' '] -- cmdline: '\"\\ \"' - result: [' '] -- cmdline: '\\\\' - result: ['\\'] -- cmdline: '\"\\\\\"' - result: ['\\'] -- cmdline: '\\\"' - result: ['\"'] -- cmdline: '\"\\\"\"' - result: ['\"'] -- cmdline: 'foo\\ ' - result: ['foo '] -- cmdline: '\"foo\\ \"' - result: ['foo '] -- cmdline: 'foo\\\\' - result: ['foo\\'] -- cmdline: '\"foo\\\\\"' - result: ['foo\\'] -- cmdline: 'foo\\\"' - result: ['foo\"'] -- cmdline: '\"foo\\\"\"' - result: ['foo\"'] -- cmdline: '\\ foo' - result: [' foo'] -- cmdline: '\"\\ foo\"' - result: [' foo'] -- cmdline: '\\\\foo' - result: ['\\foo'] -- cmdline: '\"\\\\foo\"' - result: ['\\foo'] -- cmdline: '\\\"foo' - result: ['\"foo'] -- cmdline: '\"\\\"foo\"' - result: ['\"foo'] -- cmdline: '\\ foo\\ ' - result: [' foo '] -- cmdline: '\"\\ foo\\ \"' - result: [' foo '] -- cmdline: '\\\\foo\\\\' - result: ['\\foo\\'] -- cmdline: '\"\\\\foo\\\\\"' - result: ['\\foo\\'] -- cmdline: '\\\"foo\\\"' - result: ['\"foo\"'] -- cmdline: '\"\\\"foo\\\"\"' - result: ['\"foo\"'] -- cmdline: 'foo\\ bar' - result: ['foo bar'] -- cmdline: '\"foo\\ bar\"' - result: ['foo bar'] -- cmdline: 'foo\\\\bar' - result: ['foo\\bar'] -- cmdline: '\"foo\\\\bar\"' - result: ['foo\\bar'] -- cmdline: 'foo\\\"bar' - result: ['foo\"bar'] -- cmdline: '\"foo\\\"bar\"' - result: ['foo\"bar'] -- cmdline: '\\ foo bar' - result: [' foo', 'bar'] -- cmdline: '\"\\ foo\" bar' - result: [' foo', 'bar'] -- cmdline: '\\\\foo bar' - result: ['\\foo', 'bar'] -- cmdline: '\"\\\\foo\" bar' - result: ['\\foo', 'bar'] -- cmdline: '\\\"foo bar' - result: ['\"foo', 'bar'] -- cmdline: '\"\\\"foo\" bar' - result: ['\"foo', 'bar'] -- cmdline: 'foo\\ bar' - result: ['foo ', 'bar'] -- cmdline: '\"foo\\ \" bar' - result: ['foo ', 'bar'] -- cmdline: 'foo\\\\ bar' - result: ['foo\\', 'bar'] -- cmdline: '\"foo\\\\\" bar' - result: ['foo\\', 'bar'] -- cmdline: 'foo\\\" bar' - result: ['foo\"', 'bar'] -- cmdline: '\"foo\\\"\" bar' - result: ['foo\"', 'bar'] -- cmdline: '\\ foo\\ bar' - result: [' foo ', 'bar'] -- cmdline: '\"\\ foo\\ \" bar' - result: [' foo ', 'bar'] -- cmdline: '\\\\foo\\\\ bar' - result: ['\\foo\\', 'bar'] -- cmdline: '\"\\\\foo\\\\\" bar' - result: ['\\foo\\', 'bar'] -- cmdline: '\\\"foo\\\" bar' - result: ['\"foo\"', 'bar'] -- cmdline: '\"\\\"foo\\\"\" bar' - result: ['\"foo\"', 'bar'] -- cmdline: 'foo \\ bar' - result: ['foo', ' bar'] -- cmdline: 'foo \"\\ bar\"' - result: ['foo', ' bar'] -- cmdline: 'foo \\\\bar' - result: ['foo', '\\bar'] -- cmdline: 'foo \"\\\\bar\"' - result: ['foo', '\\bar'] -- cmdline: 'foo \\\"bar' - result: ['foo', '\"bar'] -- cmdline: 'foo \"\\\"bar\"' - result: ['foo', '\"bar'] -- cmdline: 'foo bar\\ ' - result: ['foo', 'bar '] -- cmdline: 'foo \"bar\\ \"' - result: ['foo', 'bar '] -- cmdline: 'foo bar\\\\' - result: ['foo', 'bar\\'] -- cmdline: 'foo \"bar\\\\\"' - result: ['foo', 'bar\\'] -- cmdline: 'foo bar\\\"' - result: ['foo', 'bar\"'] -- cmdline: 'foo \"bar\\\"\"' - result: ['foo', 'bar\"'] -- cmdline: 'foo \\ bar\\ ' - result: ['foo', ' bar '] -- cmdline: 'foo \"\\ bar\\ \"' - result: ['foo', ' bar '] -- cmdline: 'foo \\\\bar\\\\' - result: ['foo', '\\bar\\'] -- cmdline: 'foo \"\\\\bar\\\\\"' - result: ['foo', '\\bar\\'] -- cmdline: 'foo \\\"bar\\\"' - result: ['foo', '\"bar\"'] -- cmdline: 'foo \"\\\"bar\\\"\"' - result: ['foo', '\"bar\"'] - -- cmdline: 'foo\\ bar car' - result: ["foo bar", "car"] -- cmdline: '\"foo bar\" car' - result: ["foo bar", "car"] -- cmdline: '\"foo bar\" \"car\"' - result: ["foo bar", "car"] -- cmdline: 'foo bar\\ car' - result: ['foo', 'bar car'] -- cmdline: 'foo \"bar car\"' - result: ['foo', 'bar car'] -- cmdline: '\"foo\" \"bar car\"' - result: ['foo', 'bar car'] diff --git a/fixtures/printf.yml b/fixtures/printf.yml deleted file mode 100644 index 490d7be..0000000 --- a/fixtures/printf.yml +++ /dev/null @@ -1,131 +0,0 @@ -- result: '' - args: [] -- result: '' - args: [''] -- result: '' - args: ['', ''] - -- result: 'Hello, World!' - args: ['Hello, World!'] -- result: 'Hello, Alex!' - args: ['Hello, ', ['%s', 'Alex'], '!'] -- result: 'Hello, Alex!' - args: ['Hello, ', ['%c', ['A']], ['%c', ['l']], ['%c', ['e']], ['%c', ['x']], '!'] - -- result: '%' - args: [['%%']] -- result: '%%' - args: [['%%'], ['%%']] -- result: '%%%' - args: [['%%'], ['%%'], ['%%']] - -- result: '%' - args: [['%*%', 20]] - -- result: '123' - args: [['%u', 123]] -- result: '123456' - args: [['%u', 123], ['%u', 456]] -- result: 'foo' - args: [['%s', 'foo']] -- result: 'foobar' - args: [['%s', 'foo'], ['%s', 'bar']] -- result: 'a' - args: [['%c', ['a']]] -- result: 'ab' - args: [['%c', ['a']], ['%c', ['b']]] -- result: 'abc' - args: [['%c', ['a']], ['%c', ['b']], ['%c', ['c']]] - -- result: '%123fooa' - args: [['%%'], ['%u', 123], ['%s', 'foo'], ['%c', ['a']]] -- result: '%123afoo' - args: [['%%'], ['%u', 123], ['%c', ['a']], ['%s', 'foo']] -- result: '%a123foo' - args: [['%%'], ['%c', ['a']], ['%u', 123], ['%s', 'foo']] -- result: '%afoo123' - args: [['%%'], ['%c', ['a']], ['%s', 'foo'], ['%u', 123]] -- result: '%foo123a' - args: [['%%'], ['%s', 'foo'], ['%u', 123], ['%c', ['a']]] -- result: '%fooa123' - args: [['%%'], ['%s', 'foo'], ['%c', ['a']], ['%u', 123]] -- result: '123%fooa' - args: [['%u', 123], ['%%'], ['%s', 'foo'], ['%c', ['a']]] -- result: '123%afoo' - args: [['%u', 123], ['%%'], ['%c', ['a']], ['%s', 'foo']] -- result: 'a%123foo' - args: [['%c', ['a']], ['%%'], ['%u', 123], ['%s', 'foo']] -- result: 'a%foo123' - args: [['%c', ['a']], ['%%'], ['%s', 'foo'], ['%u', 123]] -- result: 'foo%123a' - args: [['%s', 'foo'], ['%%'], ['%u', 123], ['%c', ['a']]] -- result: 'foo%a123' - args: [['%s', 'foo'], ['%%'], ['%c', ['a']], ['%u', 123]] -- result: '123foo%a' - args: [['%u', 123], ['%s', 'foo'], ['%%'], ['%c', ['a']]] -- result: '123a%foo' - args: [['%u', 123], ['%c', ['a']], ['%%'], ['%s', 'foo']] -- result: 'a123%foo' - args: [['%c', ['a']], ['%u', 123], ['%%'], ['%s', 'foo']] -- result: 'afoo%123' - args: [['%c', ['a']], ['%s', 'foo'], ['%%'], ['%u', 123]] -- result: 'foo123%a' - args: [['%s', 'foo'], ['%u', 123], ['%%'], ['%c', ['a']]] -- result: 'fooa%123' - args: [['%s', 'foo'], ['%c', ['a']], ['%%'], ['%u', 123]] -- result: '123fooa%' - args: [['%u', 123], ['%s', 'foo'], ['%c', ['a']], ['%%']] -- result: '123afoo%' - args: [['%u', 123], ['%c', ['a']], ['%s', 'foo'], ['%%']] -- result: 'a123foo%' - args: [['%c', ['a']], ['%u', 123], ['%s', 'foo'], ['%%']] -- result: 'afoo123%' - args: [['%c', ['a']], ['%s', 'foo'], ['%u', 123], ['%%']] -- result: 'foo123a%' - args: [['%s', 'foo'], ['%u', 123], ['%c', ['a']], ['%%']] -- result: 'fooa123%' - args: [['%s', 'foo'], ['%c', ['a']], ['%u', 123], ['%%']] - -- result: '1.200000' - args: [['%f', 1.2]] - float: true -- result: '123.456789' - args: [['%f', 123.456789]] - float: true - -- result: '0.01234568' - args: [['%.8f', 0.0123456789012345678901234567890123456789]] - float: true -- result: '0.012345679' - args: [['%.9f', 0.0123456789012345678901234567890123456789]] - float: true -# Actual precision is no more than 9 -- result: '0.0123456790' - args: [['%.10f', 0.0123456789012345678901234567890123456789]] - float: true -- result: '0.01234567900' - args: [['%.11f', 0.0123456789012345678901234567890123456789]] - float: true -- result: '0.012345679000' - args: [['%.12f', 0.0123456789012345678901234567890123456789]] - float: true -- result: '0.012345679000000000000000000000' - args: [['%.30f', 0.0123456789012345678901234567890123456789]] - float: true -# Actual length is no more than 32 -- result: '0.012345679000000000000000000000' - args: [['%.31f', 0.0123456789012345678901234567890123456789]] - float: true -- result: '0.012345679000000000000000000000' - args: [['%.32f', 0.0123456789012345678901234567890123456789]] - float: true -# Actual length is no more than 32 -- result: '10.01234567900000000000000000000' - args: [['%.32f', 10.0123456789012345678901234567890123456789]] - float: true -- result: '100.0123456790000000000000000000' - args: [['%.32f', 100.0123456789012345678901234567890123456789]] - float: true -- result: '1000.012345679000000000000000000' - args: [['%.32f', 1000.0123456789012345678901234567890123456789]] - float: true diff --git a/fixtures/printf_fmt.yml b/fixtures/printf_fmt.yml deleted file mode 100644 index fbd9cab..0000000 --- a/fixtures/printf_fmt.yml +++ /dev/null @@ -1,340 +0,0 @@ -- in: - format: 's' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: str - base: 0 - -- in: - format: '-s' - width: null - precision: null - out: - flags: [left] - width: 0 - precision: 0 - type: str - base: 0 - -- in: - format: '+s' - width: null - precision: null - out: - flags: [plus] - width: 0 - precision: 0 - type: str - base: 0 - -- in: - format: ' s' - width: null - precision: null - out: - flags: [space] - width: 0 - precision: 0 - type: str - base: 0 - -- in: - format: '#s' - width: null - precision: null - out: - flags: [hash] - width: 0 - precision: 0 - type: str - base: 0 - -- in: - format: '0s' - width: null - precision: null - out: - flags: [zeropad] - width: 0 - precision: 0 - type: str - base: 0 - -- in: - format: '123s' - width: null - precision: null - out: - flags: [] - width: 123 - precision: 0 - type: str - base: 0 - -- in: - format: '*s' - width: 123 - precision: null - out: - flags: [] - width: 123 - precision: 0 - type: str - base: 0 - -- in: - format: '.123s' - width: null - precision: null - out: - flags: [precision] - width: 0 - precision: 123 - type: str - base: 0 - -- in: - format: '.*s' - width: null - precision: 123 - out: - flags: [precision] - width: 0 - precision: 123 - type: str - base: 0 - -- in: - format: 'ls' - width: null - precision: null - out: - flags: [long] - width: 0 - precision: 0 - type: str - base: 0 - -- in: - format: 'lls' - width: null - precision: null - out: - flags: [long, long_long] - width: 0 - precision: 0 - type: str - base: 0 - -- in: - format: 'hs' - width: null - precision: null - out: - flags: [short] - width: 0 - precision: 0 - type: str - base: 0 - -- in: - format: 'hhs' - width: null - precision: null - out: - flags: [short, char] - width: 0 - precision: 0 - type: str - base: 0 - -- in: - format: 'd' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: int - base: 10 - -- in: - format: 'i' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: int - base: 10 - -- in: - format: 'u' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: uint - base: 10 - -- in: - format: 'x' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: uint - base: 16 - -- in: - format: 'X' - width: null - precision: null - out: - flags: [uppercase] - width: 0 - precision: 0 - type: uint - base: 16 - -- in: - format: 'o' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: uint - base: 8 - -- in: - format: 'b' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: uint - base: 2 - -- in: - format: 'f' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: float - base: 0 - -- in: - format: 'F' - width: null - precision: null - out: - flags: [uppercase] - width: 0 - precision: 0 - type: float - base: 0 - -- in: - format: 'e' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: exp - base: 0 - -- in: - format: 'E' - width: null - precision: null - out: - flags: [uppercase] - width: 0 - precision: 0 - type: exp - base: 0 - -- in: - format: 'g' - width: null - precision: null - out: - flags: [adapt_exp] - width: 0 - precision: 0 - type: exp - base: 0 - -- in: - format: 'G' - width: null - precision: null - out: - flags: [adapt_exp, uppercase] - width: 0 - precision: 0 - type: exp - base: 0 - -- in: - format: 'c' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: char - base: 0 - -- in: - format: 's' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: str - base: 0 - -- in: - format: '%' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: percent - base: 0 - -- in: - format: '_' - width: null - precision: null - out: - flags: [] - width: 0 - precision: 0 - type: none - base: 0 diff --git a/fixtures/printf_orig.yml b/fixtures/printf_orig.yml deleted file mode 100644 index a1c669c..0000000 --- a/fixtures/printf_orig.yml +++ /dev/null @@ -1,667 +0,0 @@ -# The code was taken from Marco Paland's printf. - -# Copyright (c) 2014-2019 Marco Paland -# Copyright (c) 2021-2022 Alex Kotov - -# TODO: add remaining tests from -# https://github.com/mpaland/printf/blob/master/test/test_suite.cpp - -- result: ' 4232' - args: [['% d', 4232]] -- result: 'This is a test of 12EF' - args: [['This is a test of %X', 0x12ef]] -- result: '-1000' - args: [['%d', -1000]] -- result: '-1' - args: [['%d', -1]] -- result: '2345' - args: [['%d', 2345]] -- result: '3 -1000 test' - args: [['%d ', 3], ['%d', -1000], [' %s', 'test']] -- result: '3 -1000 test' - args: [['%d ', 3], ['%d ', -1000], ['%s', 'test']] -- result: '3 -1000 test' - args: [['%d', 3], [' %d', -1000], [' %s', 'test']] -- result: '3 -1000 test' - args: [['%d', 3], ' ', ['%d', -1000], ' ', ['%s', 'test']] - -# space flag - -- result: ' 42' - args: [['% d', 42]] -- result: '-42' - args: [['% d', -42]] -- result: ' 42' - args: [['% 5d', 42]] -- result: ' -42' - args: [['% 5d', -42]] -- result: ' 42' - args: [['% 15d', 42]] -- result: ' -42' - args: [['% 15d', -42]] -- result: ' -42.987' - args: [['% 15.3f', -42.987]] - float: true -- result: ' 42.987' - args: [['% 15.3f', 42.987]] - float: true -- result: 'Hello testing' - args: [['% s', 'Hello testing']] -- result: ' 1024' - args: [['% d', 1024]] -- result: '-1024' - args: [['% d', -1024]] -- result: ' 1024' - args: [['% i', 1024]] -- result: '-1024' - args: [['% i', -1024]] -- result: '1024' - args: [['% u', 1024]] -- result: '4294966272' - args: [['% u', 4294966272]] -- result: '777' - args: [['% o', 511]] -- result: '37777777001' - args: [['% o', 4294966785]] -- result: '1234abcd' - args: [['% x', 305441741]] -- result: 'edcb5433' - args: [['% x', 3989525555]] -- result: '1234ABCD' - args: [['% X', 305441741]] -- result: 'EDCB5433' - args: [['% X', 3989525555]] -- result: 'x' - args: [['% c', ['x']]] - -# + flag - -- result: '+42' - args: [['%+d', 42]] -- result: '-42' - args: [['%+d', -42]] -- result: ' +42' - args: [['%+5d', 42]] -- result: ' -42' - args: [['%+5d', -42]] -- result: ' +42' - args: [['%+15d', 42]] -- result: ' -42' - args: [['%+15d', -42]] -- result: 'Hello testing' - args: [['%+s', 'Hello testing']] -- result: '+1024' - args: [['%+d', 1024]] -- result: '-1024' - args: [['%+d', -1024]] -- result: '+1024' - args: [['%+i', 1024]] -- result: '-1024' - args: [['%+i', -1024]] -- result: '1024' - args: [['%+u', 1024]] -- result: '4294966272' - args: [['%+u', 4294966272]] -- result: '777' - args: [['%+o', 511]] -- result: '37777777001' - args: [['%+o', 4294966785]] -- result: '1234abcd' - args: [['%+x', 305441741]] -- result: 'edcb5433' - args: [['%+x', 3989525555]] -- result: '1234ABCD' - args: [['%+X', 305441741]] -- result: 'EDCB5433' - args: [['%+X', 3989525555]] -- result: 'x' - args: [['%+c', ['x']]] -- result: '+' - args: [['%+.0d', 0]] - -# 0 flag - -- result: '42' - args: [['%0d', 42]] -- result: '42' - args: [['%0ld', 42]] -- result: '-42' - args: [['%0d', -42]] -- result: '00042' - args: [['%05d', 42]] -- result: '-0042' - args: [['%05d', -42]] -- result: '000000000000042' - args: [['%015d', 42]] -- result: '-00000000000042' - args: [['%015d', -42]] -- result: '000000000042.12' - args: [['%015.2f', 42.1234]] - float: true -- result: '00000000042.988' - args: [['%015.3f', 42.9876]] - float: true -- result: '-00000042.98760' - args: [['%015.5f', -42.9876]] - float: true - -# - flag - -- result: '42' - args: [['%-d', 42]] -- result: '-42' - args: [['%-d', -42]] -- result: '42 ' - args: [['%-5d', 42]] -- result: '-42 ' - args: [['%-5d', -42]] -- result: '42 ' - args: [['%-15d', 42]] -- result: '-42 ' - args: [['%-15d', -42]] -- result: '42' - args: [['%-0d', 42]] -- result: '-42' - args: [['%-0d', -42]] -- result: '42 ' - args: [['%-05d', 42]] -- result: '-42 ' - args: [['%-05d', -42]] -- result: '42 ' - args: [['%-015d', 42]] -- result: '-42 ' - args: [['%-015d', -42]] -- result: '42' - args: [['%0-d', 42]] -- result: '-42' - args: [['%0-d', -42]] -- result: '42 ' - args: [['%0-5d', 42]] -- result: '-42 ' - args: [['%0-5d', -42]] -- result: '42 ' - args: [['%0-15d', 42]] -- result: '-42 ' - args: [['%0-15d', -42]] -- result: '-4.200e+01 ' - args: [['%0-15.3e', -42.0]] - float: true -- result: '-42.0 ' - args: [['%0-15.3g', -42.0]] - float: true - -# # flag - -- result: '' - args: [['%#.0x', 0]] -- result: '0' - args: [['%#.1x', 0]] -- result: '' - args: [['%#.0llx', ['long long', 0]]] -- result: '0x0000614e' - args: [['%#.8x', 0x614e]] -- result: '0b110' - args: [['%#b', 6]] - -# specifier - -- result: 'Hello testing' - args: ['Hello testing'] -- result: 'Hello testing' - args: [['Hello testing%s', '']] -- result: 'Hello testing' - args: [['%s', 'Hello testing']] -- result: '1024' - args: [['%d', 1024]] -- result: '-1024' - args: [['%d', -1024]] -- result: '1024' - args: [['%i', 1024]] -- result: '-1024' - args: [['%i', -1024]] -- result: '1024' - args: [['%u', 1024]] -- result: '4294966272' - args: [['%u', 4294966272]] -- result: '777' - args: [['%o', 511]] -- result: '37777777001' - args: [['%o', 4294966785]] -- result: '1234abcd' - args: [['%x', 305441741]] -- result: 'edcb5433' - args: [['%x', 3989525555]] -- result: '1234ABCD' - args: [['%X', 305441741]] -- result: 'EDCB5433' - args: [['%X', 3989525555]] -- result: '%' - args: [['%%']] - -# width - -- result: 'Hello testing' - args: [['%1s', 'Hello testing']] -- result: '1024' - args: [['%1d', 1024]] -- result: '-1024' - args: [['%1d', -1024]] -- result: '1024' - args: [['%1i', 1024]] -- result: '-1024' - args: [['%1i', -1024]] -- result: '1024' - args: [['%1u', 1024]] -- result: '4294966272' - args: [['%1u', 4294966272]] -- result: '777' - args: [['%1o', 511]] -- result: '37777777001' - args: [['%1o', 4294966785]] -- result: '1234abcd' - args: [['%1x', 305441741]] -- result: 'edcb5433' - args: [['%1x', 3989525555]] -- result: '1234ABCD' - args: [['%1X', 305441741]] -- result: 'EDCB5433' - args: [['%1X', 3989525555]] -- result: 'x' - args: [['%1c', ['x']]] - -# width 20 - -- result: ' Hello testing' - args: [['%20s', 'Hello testing']] -- result: ' 1024' - args: [['%20d', 1024]] -- result: ' -1024' - args: [['%20d', -1024]] -- result: ' 1024' - args: [['%20i', 1024]] -- result: ' -1024' - args: [['%20i', -1024]] -- result: ' 1024' - args: [['%20u', 1024]] -- result: ' 4294966272' - args: [['%20u', 4294966272]] -- result: ' 777' - args: [['%20o', 511]] -- result: ' 37777777001' - args: [['%20o', 4294966785]] -- result: ' 1234abcd' - args: [['%20x', 305441741]] -- result: ' edcb5433' - args: [['%20x', 3989525555]] -- result: ' 1234ABCD' - args: [['%20X', 305441741]] -- result: ' EDCB5433' - args: [['%20X', 3989525555]] -- result: ' x' - args: [['%20c', ['x']]] - -# width *20 - -- result: ' Hello' - args: [['%*s', 20, 'Hello']] -- result: ' 1024' - args: [['%*d', 20, 1024]] -- result: ' -1024' - args: [['%*d', 20, -1024]] -- result: ' 1024' - args: [['%*i', 20, 1024]] -- result: ' -1024' - args: [['%*i', 20, -1024]] -- result: ' 1024' - args: [['%*u', 20, 1024]] -- result: ' 4294966272' - args: [['%*u', 20, 4294966272]] -- result: ' 777' - args: [['%*o', 20, 511]] -- result: ' 37777777001' - args: [['%*o', 20, 4294966785]] -- result: ' 1234abcd' - args: [['%*x', 20, 305441741]] -- result: ' edcb5433' - args: [['%*x', 20, 3989525555]] -- result: ' 1234ABCD' - args: [['%*X', 20, 305441741]] -- result: ' EDCB5433' - args: [['%*X', 20, 3989525555]] -- result: ' x' - args: [['%*c', 20, ['x']]] - -# width -20 - -- result: 'Hello ' - args: [['%-20s', 'Hello']] -- result: '1024 ' - args: [['%-20d', 1024]] -- result: '-1024 ' - args: [['%-20d', -1024]] -- result: '1024 ' - args: [['%-20i', 1024]] -- result: '-1024 ' - args: [['%-20i', -1024]] -- result: '1024 ' - args: [['%-20u', 1024]] -- result: '1024.1234 ' - args: [['%-20.4f', 1024.1234]] - float: true -- result: '4294966272 ' - args: [['%-20u', 4294966272]] -- result: '777 ' - args: [['%-20o', 511]] -- result: '37777777001 ' - args: [['%-20o', 4294966785]] -- result: '1234abcd ' - args: [['%-20x', 305441741]] -- result: 'edcb5433 ' - args: [['%-20x', 3989525555]] -- result: '1234ABCD ' - args: [['%-20X', 305441741]] -- result: 'EDCB5433 ' - args: [['%-20X', 3989525555]] -- result: 'x ' - args: [['%-20c', ['x']]] -- result: '| 9| |9 | | 9|' - args: [['|%5d| ', 9], ['|%-2d|', 9], [' |%5d|', 9]] -- result: '| 10| |10| | 10|' - args: [['|%5d| ', 10], ['|%-2d|', 10], [' |%5d|', 10]] -- result: '| 9| |9 | | 9|' - args: [['|%5d| ', 9], ['|%-12d|', 9], [' |%5d|', 9]] -- result: '| 10| |10 | | 10|' - args: [['|%5d| ', 10], ['|%-12d|', 10], [' |%5d|', 10]] - -# width 0-20 - -- result: 'Hello ' - args: [['%0-20s', 'Hello']] -- result: '1024 ' - args: [['%0-20d', 1024]] -- result: '-1024 ' - args: [['%0-20d', -1024]] -- result: '1024 ' - args: [['%0-20i', 1024]] -- result: '-1024 ' - args: [['%0-20i', -1024]] -- result: '1024 ' - args: [['%0-20u', 1024]] -- result: '4294966272 ' - args: [['%0-20u', 4294966272]] -- result: '777 ' - args: [['%0-20o', 511]] -- result: '37777777001 ' - args: [['%0-20o', 4294966785]] -- result: '1234abcd ' - args: [['%0-20x', 305441741]] -- result: 'edcb5433 ' - args: [['%0-20x', 3989525555]] -- result: '1234ABCD ' - args: [['%0-20X', 305441741]] -- result: 'EDCB5433 ' - args: [['%0-20X', 3989525555]] -- result: 'x ' - args: [['%0-20c', ['x']]] - -# padding 20 - -- result: '00000000000000001024' - args: [['%020d', 1024]] -- result: '-0000000000000001024' - args: [['%020d', -1024]] -- result: '00000000000000001024' - args: [['%020i', 1024]] -- result: '-0000000000000001024' - args: [['%020i', -1024]] -- result: '00000000000000001024' - args: [['%020u', 1024]] -- result: '00000000004294966272' - args: [['%020u', 4294966272]] -- result: '00000000000000000777' - args: [['%020o', 511]] -- result: '00000000037777777001' - args: [['%020o', 4294966785]] -- result: '0000000000001234abcd' - args: [['%020x', 305441741]] -- result: '000000000000edcb5433' - args: [['%020x', 3989525555]] -- result: '0000000000001234ABCD' - args: [['%020X', 305441741]] -- result: '000000000000EDCB5433' - args: [['%020X', 3989525555]] - -# padding .20 - -- result: '00000000000000001024' - args: [['%.20d', 1024]] -- result: '-00000000000000001024' - args: [['%.20d', -1024]] -- result: '00000000000000001024' - args: [['%.20i', 1024]] -- result: '-00000000000000001024' - args: [['%.20i', -1024]] -- result: '00000000000000001024' - args: [['%.20u', 1024]] -- result: '00000000004294966272' - args: [['%.20u', 4294966272]] -- result: '00000000000000000777' - args: [['%.20o', 511]] -- result: '00000000037777777001' - args: [['%.20o', 4294966785]] -- result: '0000000000001234abcd' - args: [['%.20x', 305441741]] -- result: '000000000000edcb5433' - args: [['%.20x', 3989525555]] -- result: '0000000000001234ABCD' - args: [['%.20X', 305441741]] -- result: '000000000000EDCB5433' - args: [['%.20X', 3989525555]] - -# padding #020 - -- result: '00000000000000001024' - args: [['%#020d', 1024]] -- result: '-0000000000000001024' - args: [['%#020d', -1024]] -- result: '00000000000000001024' - args: [['%#020i', 1024]] -- result: '-0000000000000001024' - args: [['%#020i', -1024]] -- result: '00000000000000001024' - args: [['%#020u', 1024]] -- result: '00000000004294966272' - args: [['%#020u', 4294966272]] -- result: '00000000000000000777' - args: [['%#020o', 511]] -- result: '00000000037777777001' - args: [['%#020o', 4294966785]] -- result: '0x00000000001234abcd' - args: [['%#020x', 305441741]] -- result: '0x0000000000edcb5433' - args: [['%#020x', 3989525555]] -- result: '0X00000000001234ABCD' - args: [['%#020X', 305441741]] -- result: '0X0000000000EDCB5433' - args: [['%#020X', 3989525555]] - -# padding #20 - -- result: ' 1024' - args: [['%#20d', 1024]] -- result: ' -1024' - args: [['%#20d', -1024]] -- result: ' 1024' - args: [['%#20i', 1024]] -- result: ' -1024' - args: [['%#20i', -1024]] -- result: ' 1024' - args: [['%#20u', 1024]] -- result: ' 4294966272' - args: [['%#20u', 4294966272]] -- result: ' 0777' - args: [['%#20o', 511]] -- result: ' 037777777001' - args: [['%#20o', 4294966785]] -- result: ' 0x1234abcd' - args: [['%#20x', 305441741]] -- result: ' 0xedcb5433' - args: [['%#20x', 3989525555]] -- result: ' 0X1234ABCD' - args: [['%#20X', 305441741]] -- result: ' 0XEDCB5433' - args: [['%#20X', 3989525555]] - -# padding 20.5 - -- result: ' 01024' - args: [['%20.5d', 1024]] -- result: ' -01024' - args: [['%20.5d', -1024]] -- result: ' 01024' - args: [['%20.5i', 1024]] -- result: ' -01024' - args: [['%20.5i', -1024]] -- result: ' 01024' - args: [['%20.5u', 1024]] -- result: ' 4294966272' - args: [['%20.5u', 4294966272]] -- result: ' 00777' - args: [['%20.5o', 511]] -- result: ' 37777777001' - args: [['%20.5o', 4294966785]] -- result: ' 1234abcd' - args: [['%20.5x', 305441741]] -- result: ' 00edcb5433' - args: [['%20.10x', 3989525555]] -- result: ' 1234ABCD' - args: [['%20.5X', 305441741]] -- result: ' 00EDCB5433' - args: [['%20.10X', 3989525555]] - -# padding neg numbers - -# space padding -- result: '-5' - args: [['% 1d', -5]] -- result: '-5' - args: [['% 2d', -5]] -- result: ' -5' - args: [['% 3d', -5]] -- result: ' -5' - args: [['% 4d', -5]] -# zero padding -- result: '-5' - args: [['%01d', -5]] -- result: '-5' - args: [['%02d', -5]] -- result: '-05' - args: [['%03d', -5]] -- result: '-005' - args: [['%04d', -5]] - -# float padding neg numbers - -# space padding -- result: '-5.0' - args: [['% 3.1f', -5.0]] - float: true -- result: '-5.0' - args: [['% 4.1f', -5.0]] - float: true -- result: ' -5.0' - args: [['% 5.1f', -5.0]] - float: true -- result: ' -5' - args: [['% 6.1g', -5.0]] - float: true -- result: '-5.0e+00' - args: [['% 6.1e', -5.0]] - float: true -- result: ' -5.0e+00' - args: [['% 10.1e', -5.0]] - float: true -# zero padding -- result: '-5.0' - args: [['%03.1f', -5.0]] - float: true -- result: '-5.0' - args: [['%04.1f', -5.0]] - float: true -- result: '-05.0' - args: [['%05.1f', -5.0]] - float: true -# zero padding no decimal point -- result: '-5' - args: [['%01.0f', -5.0]] - float: true -- result: '-5' - args: [['%02.0f', -5.0]] - float: true -- result: '-05' - args: [['%03.0f', -5.0]] - float: true -- result: '-005.0e+00' - args: [['%010.1e', -5.0]] - float: true -- result: '-05E+00' - args: [['%07.0E', -5.0]] - float: true -- result: '-05' - args: [['%03.0g', -5.0]] - float: true - -# length - -- result: '' - args: [['%.0s', 'Hello testing']] -- result: ' ' - args: [['%20.0s', 'Hello testing']] -- result: '' - args: [['%.s', 'Hello testing']] -- result: ' ' - args: [['%20.s', 'Hello testing']] -- result: ' 1024' - args: [['%20.0d', 1024]] -- result: ' -1024' - args: [['%20.0d', -1024]] -- result: ' ' - args: [['%20.d', 0]] -- result: ' 1024' - args: [['%20.0i', 1024]] -- result: ' -1024' - args: [['%20.i', -1024]] -- result: ' ' - args: [['%20.i', 0]] -- result: ' 1024' - args: [['%20.u', 1024]] -- result: ' 4294966272' - args: [['%20.0u', 4294966272]] -- result: ' ' - args: [['%20.u', 0]] -- result: ' 777' - args: [['%20.o', 511]] -- result: ' 37777777001' - args: [['%20.0o', 4294966785]] -- result: ' ' - args: [['%20.o', 0]] -- result: ' 1234abcd' - args: [['%20.x', 305441741]] -- result: ' 1234abcd' - args: [['%50.x', 305441741]] -- result: ' 1234abcd 12345' - args: [['%50.x', 305441741], ['%10.u', 12345]] -- result: ' edcb5433' - args: [['%20.0x', 3989525555]] -- result: ' ' - args: [['%20.x', 0]] -- result: ' 1234ABCD' - args: [['%20.X', 305441741]] -- result: ' EDCB5433' - args: [['%20.0X', 3989525555]] -- result: ' ' - args: [['%20.X', 0]] -- result: ' ' - args: [['%02.0u', 0]] -- result: ' ' - args: [['%02.0d', 0]] diff --git a/tests/.gitignore b/tests/.gitignore index 957f241..305f4be 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -6,8 +6,6 @@ /multiboot2_info_print2 /test_arch_i386 /test_cmdline -/test_cmdline_gen -/test_cmdline_gen.c /test_elf /test_free_list /test_mbr @@ -26,8 +24,4 @@ /test_pfa /test_pfa_assert /test_printf -/test_printf_fmt_gen -/test_printf_fmt_gen.c -/test_printf_gen -/test_printf_gen.c /test_units_human diff --git a/tests/Makefile.am b/tests/Makefile.am index 3fc5cbc..810f143 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -108,30 +108,6 @@ test_cmdline_SOURCES = \ cmdline_test.c endif -#################### -# test_cmdline_gen # -#################### - -if ENABLE_CHECKS_PYTHON -if WITH_CMDLINE -TESTS += test_cmdline_gen -test_cmdline_gen_LDADD = $(top_builddir)/libkernaux.la -test_cmdline_gen_SOURCES = \ - main.c \ - test_cmdline_gen.c \ - cmdline_gen.py \ - cmdline_gen.jinja \ - $(top_srcdir)/fixtures/cmdline.yml \ - cmdline_test.h \ - cmdline_test.c -endif -endif - -CLEANFILES += test_cmdline_gen.c - -test_cmdline_gen.c: $(top_srcdir)/tests/cmdline_gen.py $(top_srcdir)/tests/cmdline_gen.jinja $(top_srcdir)/fixtures/cmdline.yml - $(PYTHON) $(top_srcdir)/tests/cmdline_gen.py $(top_srcdir)/tests/cmdline_gen.jinja $(top_srcdir)/fixtures/cmdline.yml test_cmdline_gen.c - ############ # test_elf # ############ @@ -356,51 +332,6 @@ test_printf_SOURCES = \ test_printf.c endif -####################### -# test_printf_fmt_gen # -####################### - -if ENABLE_CHECKS_PYTHON -if WITH_PRINTF_FMT -TESTS += test_printf_fmt_gen -test_printf_fmt_gen_LDADD = $(top_builddir)/libkernaux.la -test_printf_fmt_gen_SOURCES = \ - main.c \ - test_printf_fmt_gen.c \ - printf_fmt_gen.py \ - printf_fmt_gen.jinja \ - $(top_srcdir)/fixtures/printf_fmt.yml -endif -endif - -CLEANFILES += test_printf_fmt_gen.c - -test_printf_fmt_gen.c: $(top_srcdir)/tests/printf_fmt_gen.py $(top_srcdir)/tests/printf_fmt_gen.jinja $(top_srcdir)/fixtures/printf_fmt.yml - $(PYTHON) $(top_srcdir)/tests/printf_fmt_gen.py $(top_srcdir)/tests/printf_fmt_gen.jinja $(top_srcdir)/fixtures/printf_fmt.yml test_printf_fmt_gen.c - -################### -# test_printf_gen # -################### - -if ENABLE_CHECKS_PYTHON -if WITH_PRINTF -TESTS += test_printf_gen -test_printf_gen_LDADD = $(top_builddir)/libkernaux.la -test_printf_gen_SOURCES = \ - main.c \ - test_printf_gen.c \ - printf_gen.py \ - printf_gen.jinja \ - $(top_srcdir)/fixtures/printf.yml \ - $(top_srcdir)/fixtures/printf_orig.yml -endif -endif - -CLEANFILES += test_printf_gen.c - -test_printf_gen.c: $(top_srcdir)/tests/printf_gen.py $(top_srcdir)/tests/printf_gen.jinja $(top_srcdir)/fixtures/printf.yml $(top_srcdir)/fixtures/printf_orig.yml - $(PYTHON) $(top_srcdir)/tests/printf_gen.py $(top_srcdir)/tests/printf_gen.jinja $(top_srcdir)/fixtures/printf.yml $(top_srcdir)/fixtures/printf_orig.yml test_printf_gen.c - #################### # test_units_human # #################### diff --git a/tests/cmdline_gen.jinja b/tests/cmdline_gen.jinja deleted file mode 100644 index 1148616..0000000 --- a/tests/cmdline_gen.jinja +++ /dev/null @@ -1,46 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "cmdline_test.h" - -#include -#include -#include -#include - -void test_main() -{ - {% for case in cases %} - { - {% if not case.error and len(case.result) %} - const char *const expected_argv[] = { - {% for item in case.result %} - {{ escape_str(item) }}, - {% endfor %} - }; - {% endif %} - - test( - {{ escape_str(case.cmdline) }}, - {{ escape_int(case.arg_count_max or 0) }}, - {{ escape_int(case.buffer_size or 0) }}, - {% if not case.error %} - true, - "", - {{ escape_int(len(case.result)) }}, - {% if len(case.result) %} - expected_argv - {% else %} - NULL - {% endif %} - {% else %} - false, - {{ escape_str(case.error) }}, - 0, - NULL - {% endif %} - ); - } - {% endfor %} -} diff --git a/tests/cmdline_gen.py b/tests/cmdline_gen.py deleted file mode 100644 index 32883dc..0000000 --- a/tests/cmdline_gen.py +++ /dev/null @@ -1,49 +0,0 @@ -from jinja2 import Environment, FileSystemLoader -from os import path -from sys import argv -from yaml import safe_load - -def main(test_filepath, template_filepath, cases_filepath): - cases = safe_load(open(cases_filepath)) - - jinja_env = Environment( - keep_trailing_newline=True, - loader=FileSystemLoader(path.dirname(template_filepath)), - ) - jinja_template = jinja_env.get_template(path.basename(template_filepath)) - - result = jinja_template.render( - cases=cases, - escape_str=escape_str, - escape_int=escape_int, - len=len, - ) - - with open(test_filepath, 'w') as f: - f.write(result) - -def escape_int(n): - return str(n) - -def escape_str(s): - return '"' + s + '"' - -if __name__ == '__main__': - print(argv) - - template_filepath = argv[1] - cases_filepath = argv[2] - test_filepath = argv[3] - - print('test_filepath: %s' % test_filepath) - print('template_filepath: %s' % template_filepath) - print('cases_filepath: %s' % cases_filepath) - - if path.exists(test_filepath) and not path.isfile(test_filepath): - raise RuntimeError('invalid test file path') - if not path.isfile(template_filepath): - raise RuntimeError('invalid template file path') - if not path.isfile(cases_filepath): - raise RuntimeError('invalid cases file path') - - main(test_filepath, template_filepath, cases_filepath) diff --git a/tests/printf_fmt_gen.jinja b/tests/printf_fmt_gen.jinja deleted file mode 100644 index adc774a..0000000 --- a/tests/printf_fmt_gen.jinja +++ /dev/null @@ -1,36 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include - -#include -#include - -#include - -void test_main() -{ - {% for case in cases %} - { - const char *const format = {{ escape_str(case.in.format) }}; - - struct KernAux_PrintfFmt_Spec spec = KernAux_PrintfFmt_Spec_create(format); - - if (spec.set_width) { - KernAux_PrintfFmt_Spec_set_width(&spec, {{ none_to_zero(case.in.width) }}); - } - if (spec.set_precision) { - KernAux_PrintfFmt_Spec_set_precision(&spec, {{ none_to_zero(case.in.precision) }}); - } - - assert(spec.format_start == format); - - assert(spec.flags == {{ escape_flags(case.out.flags) }}); - assert(spec.width == {{ case.out.width }}); - assert(spec.precision == {{ case.out.precision }}); - assert(spec.type == {{ escape_type(case.out.type) }}); - assert(spec.base == {{ case.out.base }}); - } - {% endfor %} -} diff --git a/tests/printf_fmt_gen.py b/tests/printf_fmt_gen.py deleted file mode 100644 index 96a0925..0000000 --- a/tests/printf_fmt_gen.py +++ /dev/null @@ -1,65 +0,0 @@ -from jinja2 import Environment, FileSystemLoader -from os import path -from sys import argv -from yaml import safe_load - -def main(test_filepath, template_filepath, cases_filepath): - cases = safe_load(open(cases_filepath)) - - jinja_env = Environment( - keep_trailing_newline=True, - loader=FileSystemLoader(path.dirname(template_filepath)), - ) - jinja_template = jinja_env.get_template(path.basename(template_filepath)) - - result = jinja_template.render( - cases=cases, - escape_flags=escape_flags, - escape_str=escape_str, - escape_type=escape_type, - none_to_zero=none_to_zero, - ) - - with open(test_filepath, 'w') as f: - f.write(result) - -def escape_flag(flag): - return 'KERNAUX_PRINTF_FMT_FLAGS_' + flag.upper() - -def escape_flags(flags): - if len(flags) == 0: - return '0' - - return '(' + ' | '.join(map(escape_flag, flags)) + ')' - -def escape_str(s): - return '"' + s + '"' - -def escape_type(type_): - return 'KERNAUX_PRINTF_FMT_TYPE_' + type_.upper() - -def none_to_zero(num): - if num is None: - return '0' - else: - return str(num) - -if __name__ == '__main__': - print(argv) - - template_filepath = argv[1] - cases_filepath = argv[2] - test_filepath = argv[3] - - print('test_filepath: %s' % test_filepath) - print('template_filepath: %s' % template_filepath) - print('cases_filepath: %s' % cases_filepath) - - if path.exists(test_filepath) and not path.isfile(test_filepath): - raise RuntimeError('invalid test file path') - if not path.isfile(template_filepath): - raise RuntimeError('invalid template file path') - if not path.isfile(cases_filepath): - raise RuntimeError('invalid cases file path') - - main(test_filepath, template_filepath, cases_filepath) diff --git a/tests/printf_gen.jinja b/tests/printf_gen.jinja deleted file mode 100644 index 3d1cf4a..0000000 --- a/tests/printf_gen.jinja +++ /dev/null @@ -1,76 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#define KERNAUX_ACCESS_PROTECTED - -#include -#include - -#include -#include -#include -#include -#include - -#define BUFFER_SIZE 1024 - -static const char *const data = "foobar"; - -static char buffer[BUFFER_SIZE]; -static size_t buffer_index; - -static void test_putc(char c, void *arg KERNAUX_UNUSED) -{ - if (buffer_index >= BUFFER_SIZE) { - printf("Buffer overflow!\n"); - abort(); - } - - buffer[buffer_index++] = c; -} - -static void test(const char *const expected, const char *const format, ...) -{ - va_list va; - int result; - - memset(buffer, '\0', sizeof(buffer)); - buffer_index = 0; - va_start(va, format); - result = kernaux_vfprintf(test_putc, (void*)data, format, va); - va_end(va); - - printf("Exp: %s\n", expected); - printf("Got: %s\n\n", buffer); - - assert((size_t)result == strlen(expected)); - assert(strcmp(expected, buffer) == 0); - - memset(buffer, '\0', sizeof(buffer)); - buffer_index = 0; - va_start(va, format); - result = kernaux_vsnprintf(buffer, sizeof(buffer), format, va); - va_end(va); - - assert((size_t)result == strlen(expected)); - assert(strcmp(expected, buffer) == 0); -} - -void test_main() -{ - memset(buffer, '\0', sizeof(buffer)); - buffer_index = 0; - kernaux_fprintf(test_putc, (void*)data, "Hello, World!"); - assert(strcmp("Hello, World!", buffer) == 0); - - {% for case in cases %} - {% if case.float %} -#ifdef ENABLE_FLOAT - {% endif %} - test({{ escape_str(case.result) }}, {{ escape_str(fmt(case.args)) }}{{ values(case.args) }}); - {% if case.float %} -#endif - {% endif %} - {% endfor %} -} diff --git a/tests/printf_gen.py b/tests/printf_gen.py deleted file mode 100644 index 2841a14..0000000 --- a/tests/printf_gen.py +++ /dev/null @@ -1,88 +0,0 @@ -from jinja2 import Environment, FileSystemLoader -from os import path -from sys import argv -from yaml import safe_load - -def main(test_filepath, template_filepath, cases_reg_filepath, cases_orig_filepath): - cases_reg = safe_load(open(cases_reg_filepath)) - cases_orig = safe_load(open(cases_orig_filepath)) - - cases = cases_reg + cases_orig - - jinja_env = Environment( - keep_trailing_newline=True, - loader=FileSystemLoader(path.dirname(template_filepath)), - ) - jinja_template = jinja_env.get_template(path.basename(template_filepath)) - - result = jinja_template.render( - cases=cases, - escape_str=escape_str, - fmt=fmt, - values=values, - ) - - with open(test_filepath, 'w') as f: - f.write(result) - -def escape_char(c): - return "'" + c + "'" - -def escape_str(s): - return '"' + s + '"' - -def fmt(args): - fmt = '' - for arg in args: - if type(arg) is list: - fmt += arg[0] - else: - fmt += arg - return fmt - -def values(args): - values = '' - - for arg in args: - if type(arg) is list and len(arg) >= 2: - if len(arg) >= 3: - values += ', ' + str(arg[1]) - arg[1] = arg[2] - - if type(arg[1]) is str: - values += ', ' + escape_str(arg[1]) - elif type(arg[1]) is list: - if len(arg[1]) == 1: - values += ', ' + escape_char(arg[1][0]) - elif arg[1][0] == 'long long': - values += ', (long long)' + str(arg[1][1]) - else: - raise RuntimeError('unknown format: ' + str(args)) - else: - values += ', ' + str(arg[1]) - - return values - -if __name__ == '__main__': - print(argv) - - template_filepath = argv[1] - cases_reg_filepath = argv[2] - cases_orig_filepath = argv[3] - test_filepath = argv[4] - - print('test_filepath: %s' % test_filepath) - print('template_filepath: %s' % template_filepath) - print('cases_reg_filepath: %s' % cases_reg_filepath) - print('cases_orig_filepath: %s' % cases_orig_filepath) - - if path.exists(test_filepath) and not path.isfile(test_filepath): - raise RuntimeError('invalid test file path') - if not path.isfile(template_filepath): - raise RuntimeError('invalid template file path') - if not path.isfile(cases_reg_filepath): - raise RuntimeError('invalid regular cases file path') - if not path.isfile(cases_orig_filepath): - raise RuntimeError('invalid original cases file path') - - main(test_filepath, template_filepath, cases_reg_filepath, cases_orig_filepath)