]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add string.printf() test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 14 Nov 2020 20:31:03 +0000 (21:31 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 14 Nov 2020 20:31:03 +0000 (21:31 +0100)
tests/Makefile.am
tests/basic-types/strings.vala
tests/posix/string-printf.vala [new file with mode: 0644]

index 48aa3a55cd90eebbafb74ffde7d4daaf9332d2e2..2b3061793a4105b5c5e705c9262875da29a3fc85 100644 (file)
@@ -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 \
index 219dde7c848c0a5769b242207a08541dd918030f..e1aa55ff133e043ee57bf686ea929edd2b9f2a6e 100644 (file)
@@ -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 (file)
index 0000000..a8c62c3
--- /dev/null
@@ -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");
+}