[vala/staging: 8/10] tests: Add string.printf() test to increase coverage




commit 9117a6b79dc32731f84968553dfffb3336e27aac
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sat Nov 14 21:31:03 2020 +0100

    tests: Add string.printf() test to increase coverage

 tests/Makefile.am              | 1 +
 tests/basic-types/strings.vala | 6 ++++++
 tests/posix/string-printf.vala | 4 ++++
 3 files changed, 11 insertions(+)
---
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");
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]