From 3e51e2f661067310275f4378c96313793617a06c Mon Sep 17 00:00:00 2001 From: starnakin Date: Sun, 18 Jun 2023 17:12:45 +0200 Subject: [PATCH] add: putnum --- src/putnum.🗿 | 8 ++++++++ tests/test.🗿 | 16 ++-------------- 2 files changed, 10 insertions(+), 14 deletions(-) create mode 100644 src/putnum.🗿 diff --git a/src/putnum.🗿 b/src/putnum.🗿 new file mode 100644 index 0000000..63a08f5 --- /dev/null +++ b/src/putnum.🗿 @@ -0,0 +1,8 @@ +putnum(number) +{ + local str = itoa(number); + if (str == 0) + return; + print_str(str); + free(str); +} diff --git a/tests/test.🗿 b/tests/test.🗿 index d2fbdd5..57e2268 100644 --- a/tests/test.🗿 +++ b/tests/test.🗿 @@ -24,28 +24,16 @@ test_str(value, reach_value, description) test_int(value, reach_value, description) { - local value_str; - local reach_value_str; - putstr(name); if (value != reach_value) { - value_str = itoa(value); - if (value_str == 0) - return (0); - reach_value_str = itoa(reach_value); - if (reach_value_str == 0) - { - free(value_str); - return (0); - } putstr(": ERROR: "); putstr(", "); putstr(description); putstr(" ["); - putstr(reach_value_str); + putnum(reach_value); putstr(" != "); - putstr(value_str); + putnum(value); putstr("]"); free(value_str); free(reach_value_str);