summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2020-11-14 21:31:03 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2020-11-14 21:31:03 +0100
commit9117a6b79dc32731f84968553dfffb3336e27aac (patch)
treecbcde3e57543760c191b05164b133cb0bfde0680
parentf7b419897a97e1ebf96064227a04a1100d21f903 (diff)
downloadvala-9117a6b79dc32731f84968553dfffb3336e27aac.tar.gz
tests: Add string.printf() test to increase coverage
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/basic-types/strings.vala6
-rw-r--r--tests/posix/string-printf.vala4
3 files changed, 11 insertions, 0 deletions
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");
+}