From: Rico Tzschichholz Date: Sat, 14 Nov 2020 20:31:03 +0000 (+0100) Subject: tests: Add string.printf() test to increase coverage X-Git-Tag: 0.51.1~156 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9117a6b79dc32731f84968553dfffb3336e27aac;p=thirdparty%2Fvala.git tests: Add string.printf() test to increase coverage --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 48aa3a55c..2b3061793 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1129,6 +1129,7 @@ LINUX_TESTS += \ linux/file-commandpipe.vala \ posix/arrays.vala \ posix/empty-length-0.vala \ + posix/string-printf.vala \ posix/struct_only.vala \ posix/delegate_only.vala \ posix/enum_only.vala \ diff --git a/tests/basic-types/strings.vala b/tests/basic-types/strings.vala index 219dde7c8..e1aa55ff1 100644 --- a/tests/basic-types/strings.vala +++ b/tests/basic-types/strings.vala @@ -62,6 +62,11 @@ void test_string_joinv () { assert (s == ""); } +void test_string_printf () { + string s = "%i %s %u %.4f".printf (42, "foo", 4711U, 3.1415); + assert (s == "42 foo 4711 3.1415"); +} + void test_string_replace () { string s = "hellomyworld"; @@ -132,6 +137,7 @@ void test_string_substring () { void main () { test_string (); test_string_joinv (); + test_string_printf (); test_string_replace (); test_string_slice (); test_string_splice (); diff --git a/tests/posix/string-printf.vala b/tests/posix/string-printf.vala new file mode 100644 index 000000000..a8c62c384 --- /dev/null +++ b/tests/posix/string-printf.vala @@ -0,0 +1,4 @@ +void main () { + string s = "%i %s %u %.4f".printf (42, "foo", 4711U, 3.1415); + assert (s == "42 foo 4711 3.1415"); +}