summaryrefslogtreecommitdiff
path: root/graphs/piscine/tinyprintf/tests/tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'graphs/piscine/tinyprintf/tests/tests.c')
-rw-r--r--graphs/piscine/tinyprintf/tests/tests.c213
1 files changed, 0 insertions, 213 deletions
diff --git a/graphs/piscine/tinyprintf/tests/tests.c b/graphs/piscine/tinyprintf/tests/tests.c
deleted file mode 100644
index 4235203..0000000
--- a/graphs/piscine/tinyprintf/tests/tests.c
+++ /dev/null
@@ -1,213 +0,0 @@
-#include <criterion/criterion.h>
-#include <criterion/assert.h>
-#include <criterion/redirect.h>
-#include <stdio.h>
-
-#include "../src/tinyprintf.h"
-
-TestSuite(TestHandleD);
-
-Test(TestHandleD, handle_d42, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_d(42, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("42");
- cr_expect(res == 2, "Expected: %d. Got: %d", 2, res);
-}
-
-Test(TestHandleD, handle_d0, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_d(0, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("0");
- cr_expect(res == 1, "Expected: %d. Got: %d", 1, res);
-}
-
-Test(TestHandleD, handle_dminus42, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_d(-42, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("-42");
- cr_expect(res == 3, "Expected: %d. Got: %d", 3, res);
-}
-
-Test(TestHandleD, simple_print, .init = cr_redirect_stdout)
-{
- int retval = tinyprintf("%s [%d] %s", "Hello", 42, "world!");
- fflush(stdout);
- cr_assert_stdout_eq_str("Hello [42] world!");
- cr_expect(retval == 17, "Expected: %d. Got: %d", 17, retval);
-}
-
-TestSuite(TestHandleX);
-
-Test(TestHandleX, handle_x42, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_x(42, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("2a");
- cr_expect(res == 2, "Expected: %d. Got: %d", 2, res);
-}
-
-Test(TestHandleX, handle_x0, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_x(0, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("0");
- cr_expect(res == 1, "Expected: %d. Got: %d", 1, res);
-}
-
-Test(TestHandleX, handle_x15, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_x(15, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("f");
- cr_expect(res == 1, "Expected: %d. Got: %d", 1, res);
-}
-
-Test(TestHandleX, handle_0xdeadc0de, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_x(0xdeadc0de, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("deadc0de");
- cr_expect(res == 8, "Expected: %d. Got: %d", 8, res);
-}
-
-Test(TestHandleX, simple_print_hexa, .init = cr_redirect_stdout)
-{
- int retval = tinyprintf("%s [%x] %s", "Hello", 42, "world!");
- fflush(stdout);
- cr_assert_stdout_eq_str("Hello [2a] world!");
- cr_expect(retval == 17, "Expected: %d. Got: %d", 17, retval);
-}
-
-TestSuite(TestHandleU);
-
-Test(TestHandleU, handle_u42, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_u(42, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("42");
- cr_expect(res == 2, "Expected: %d. Got: %d", 2, res);
-}
-
-Test(TestHandleU, handle_u0, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_u(0, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("0");
- cr_expect(res == 1, "Expected: %d. Got: %d", 1, res);
-}
-
-Test(TestHandleU, handle_u15, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_u(15, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("15");
- cr_expect(res == 2, "Expected: %d. Got: %d", 2, res);
-}
-
-Test(TestHandleU, simple_print_unsigned, .init = cr_redirect_stdout)
-{
- int retval = tinyprintf("%s [%u] %s", "Hello", 42, "world!");
- fflush(stdout);
- cr_assert_stdout_eq_str("Hello [42] world!");
- cr_expect(retval == 17, "Expected: %d. Got: %d", 17, retval);
-}
-
-TestSuite(TestHandleO);
-
-Test(TestHandleO, handle_o42, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_o(42, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("52");
- cr_expect(res == 2, "Expected: %d. Got: %d", 2, res);
-}
-
-Test(TestHandleO, handle_o0, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_o(0, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("0");
- cr_expect(res == 1, "Expected: %d. Got: %d", 1, res);
-}
-
-Test(TestHandleO, handle_o7, .init = cr_redirect_stdout)
-{
- int res = 0;
- handle_o(7, &res);
- fflush(stdout);
- cr_assert_stdout_eq_str("7");
- cr_expect(res == 1, "Expected: %d. Got: %d", 1, res);
-}
-
-Test(TestHandleO, simple_print_octal, .init = cr_redirect_stdout)
-{
- int retval = tinyprintf("%s [%o] %s", "Hello", 42, "world!");
- fflush(stdout);
- cr_assert_stdout_eq_str("Hello [52] world!");
- cr_expect(retval == 17, "Expected: %d. Got: %d", 17, retval);
-}
-
-TestSuite(TestPrint);
-
-Test(TestPrint, print_percent, .init = cr_redirect_stdout)
-{
- int retval = tinyprintf("%%s", "in your head");
- fflush(stdout);
- cr_assert_stdout_eq_str("%s");
- cr_expect(retval == 2, "Expected: %d. Got: %d", 2, retval);
-}
-
-Test(TestPrint, print_unknown_option, .init = cr_redirect_stdout)
-{
- int retval = tinyprintf("Good morning ACU! %t Tinyprintf is cool", 12);
- fflush(stdout);
- cr_assert_stdout_eq_str("Good morning ACU! %t Tinyprintf is cool");
- cr_expect(retval == 39, "Expected: %d. Got: %d", 39, retval);
-}
-
-Test(TestPrint, print_tricky, .init = cr_redirect_stdout)
-{
- int retval = tinyprintf("%c%c is %s... %d too.", '4', '2', "the answer", '*');
- fflush(stdout);
- cr_assert_stdout_eq_str("42 is the answer... 42 too.");
- cr_expect(retval == 27, "Expected: %d. Got: %d", 27, retval);
-}
-
-Test(TestPrint, print_null, .init = cr_redirect_stdout)
-{
- int retval = tinyprintf("%c%c is %s... %d too.", '4', '2', NULL, '*');
- fflush(stdout);
- cr_assert_stdout_eq_str("42 is (null)... 42 too.");
- cr_expect(retval == 23, "Expected: %d. Got: %d", 23, retval);
-}
-
-Test(TestPrint, print_null_fmt, .init = cr_redirect_stdout)
-{
- int retval = tinyprintf(NULL, '4', '2', NULL, '*');
- fflush(stdout);
- cr_assert_stdout_eq_str("");
- cr_expect(retval == 0, "Expected: %d. Got: %d", 0, retval);
-}
-
-Test(TestPrint, print_empty_fmt, .init = cr_redirect_stdout)
-{
- int retval = tinyprintf("", '4', '2', NULL, '*');
- fflush(stdout);
- cr_assert_stdout_eq_str("");
- cr_expect(retval == 0, "Expected: %d. Got: %d", 0, retval);
-}