[vala/0.48] tests: Add "string switch" test to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.48] tests: Add "string switch" test to increase coverage
- Date: Sun, 3 Jan 2021 11:31:49 +0000 (UTC)
commit ace2b190a26b996b87147a3685ba2909dc42b658
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Jan 2 14:12:11 2021 +0100
tests: Add "string switch" test to increase coverage
tests/Makefile.am | 1 +
tests/control-flow/switch-string.vala | 42 +++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index db2636452..7645c42c7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -256,6 +256,7 @@ TESTS = \
control-flow/pre-post-increment-parameter.vala \
control-flow/pre-post-increment-property.vala \
control-flow/switch.vala \
+ control-flow/switch-string.vala \
control-flow/sideeffects.vala \
control-flow/unassigned-captured-local-variable.test \
control-flow/unassigned-local-block-variable.test \
diff --git a/tests/control-flow/switch-string.vala b/tests/control-flow/switch-string.vala
new file mode 100644
index 000000000..bc015692a
--- /dev/null
+++ b/tests/control-flow/switch-string.vala
@@ -0,0 +1,42 @@
+const string FOO = "foo";
+const string BAR = "bar";
+const string MANAM = "manam";
+
+string foo () {
+ string foo = "foo";
+
+ switch (foo) {
+ case FOO:
+ break;
+ case BAR:
+ case MANAM:
+ assert_not_reached ();
+ case "minim":
+ assert_not_reached ();
+ }
+
+ return foo;
+}
+
+string get_bar () {
+ return "bar";
+}
+
+string bar () {
+ switch (get_bar ()) {
+ case BAR:
+ break;
+ case FOO:
+ case "minim":
+ assert_not_reached ();
+ default:
+ assert_not_reached ();
+ }
+
+ return BAR;
+}
+
+void main () {
+ assert (foo () == "foo");
+ assert (bar () == "bar");
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]