From 688cff0d23ea808ca990606d99cb15e6f61e8f90 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Mon, 7 Dec 2020 05:49:18 +0500 Subject: [PATCH] Add more tests for "kernaux_printf_va" --- tests/test_printf.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tests/test_printf.c b/tests/test_printf.c index 603dbde..bda5c4b 100644 --- a/tests/test_printf.c +++ b/tests/test_printf.c @@ -43,7 +43,39 @@ int main() test("Hello, Alex!", "Hello, %s!", "Alex"); test("Hello, Alex!", "Hello, %c%c%c%c!", 'A', 'l', 'e', 'x'); test("%", "%%"); + test("%%", "%%%%"); + test("%%%", "%%%%%%"); test("123", "%u", 123); + test("123456", "%u%u", 123, 456); + test("foo", "%s", "foo"); + test("foobar", "%s%s", "foo", "bar"); + test("a", "%c", 'a'); + test("ab", "%c%c", 'a', 'b'); + test("abc", "%c%c%c", 'a', 'b', 'c'); + test("%123fooa", "%%%u%s%c", 123, "foo", 'a'); + test("%123afoo", "%%%u%c%s", 123, 'a', "foo"); + test("%a123foo", "%%%c%u%s", 'a', 123, "foo"); + test("%afoo123", "%%%c%s%u", 'a', "foo", 123); + test("%foo123a", "%%%s%u%c", "foo", 123, 'a'); + test("%fooa123", "%%%s%c%u", "foo", 'a', 123); + test("123%fooa", "%u%%%s%c", 123, "foo", 'a'); + test("123%afoo", "%u%%%c%s", 123, 'a', "foo"); + test("a%123foo", "%c%%%u%s", 'a', 123, "foo"); + test("a%foo123", "%c%%%s%u", 'a', "foo", 123); + test("foo%123a", "%s%%%u%c", "foo", 123, 'a'); + test("foo%a123", "%s%%%c%u", "foo", 'a', 123); + test("123foo%a", "%u%s%%%c", 123, "foo", 'a'); + test("123a%foo", "%u%c%%%s", 123, 'a', "foo"); + test("a123%foo", "%c%u%%%s", 'a', 123, "foo"); + test("afoo%123", "%c%s%%%u", 'a', "foo", 123); + test("foo123%a", "%s%u%%%c", "foo", 123, 'a'); + test("fooa%123", "%s%c%%%u", "foo", 'a', 123); + test("123fooa%", "%u%s%c%%", 123, "foo", 'a'); + test("123afoo%", "%u%c%s%%", 123, 'a', "foo"); + test("a123foo%", "%c%u%s%%", 'a', 123, "foo"); + test("afoo123%", "%c%s%u%%", 'a', "foo", 123); + test("foo123a%", "%s%u%c%%", "foo", 123, 'a'); + test("fooa123%", "%s%c%u%%", "foo", 'a', 123); return 0; }