summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2022-12-13 16:04:42 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2022-12-22 14:28:10 +0100
commit07d18c71941f8db4177549afa560b798206659b3 (patch)
tree400c27772dcf192f8a81b474da4710dcfc819d39 /tests
parent5e2bc93574a9ae501bed6d5a5c7e53df454cbac9 (diff)
downloadvala-07d18c71941f8db4177549afa560b798206659b3.tar.gz
tests: Add "string relation" tests to increase coverage
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/basic-types/string-relation.c-expected35
-rw-r--r--tests/basic-types/string-relation.vala13
3 files changed, 49 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d2aae5836..94346acf3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -67,6 +67,7 @@ TESTS = \
basic-types/strings.vala \
basic-types/string-array-append.vala \
basic-types/string-concat-null.test \
+ basic-types/string-relation.vala \
basic-types/arrays.vala \
basic-types/arrays-generics.vala \
basic-types/arrays-fixed-assignment.vala \
diff --git a/tests/basic-types/string-relation.c-expected b/tests/basic-types/string-relation.c-expected
new file mode 100644
index 000000000..8fcb00f5d
--- /dev/null
+++ b/tests/basic-types/string-relation.c-expected
@@ -0,0 +1,35 @@
+/* basic_types_string_relation.c generated by valac, the Vala compiler
+ * generated from basic_types_string_relation.vala, do not modify */
+
+#include <glib.h>
+
+#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
+#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
+#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
+#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
+
+static void _vala_main (void);
+
+static void
+_vala_main (void)
+{
+ _vala_assert (g_strcmp0 ("a", "a") == 0, "\"a\" == \"a\"");
+ _vala_assert (g_strcmp0 ("a", "b") != 0, "\"a\" != \"b\"");
+ _vala_assert (g_strcmp0 ("a", "b") < 0, "\"a\" < \"b\"");
+ _vala_assert (g_strcmp0 ("b", "a") > 0, "\"b\" > \"a\"");
+ _vala_assert (g_strcmp0 ("a", "a") >= 0, "\"a\" >= \"a\"");
+ _vala_assert (g_strcmp0 ("b", "a") >= 0, "\"b\" >= \"a\"");
+ _vala_assert (g_strcmp0 ("b", "b") <= 0, "\"b\" <= \"b\"");
+ _vala_assert (g_strcmp0 ("a", "b") <= 0, "\"a\" <= \"b\"");
+ _vala_assert (g_strcmp0 (NULL, "a") < 0, "null < \"a\"");
+ _vala_assert (g_strcmp0 ("a", NULL) > 0, "\"a\" > null");
+}
+
+int
+main (int argc,
+ char ** argv)
+{
+ _vala_main ();
+ return 0;
+}
+
diff --git a/tests/basic-types/string-relation.vala b/tests/basic-types/string-relation.vala
new file mode 100644
index 000000000..5803927eb
--- /dev/null
+++ b/tests/basic-types/string-relation.vala
@@ -0,0 +1,13 @@
+void main () {
+ assert ("a" == "a");
+ assert ("a" != "b");
+ assert ("a" < "b");
+ assert ("b" > "a");
+ assert ("a" >= "a");
+ assert ("b" >= "a");
+ assert ("b" <= "b");
+ assert ("a" <= "b");
+
+ assert (null < "a");
+ assert ("a" > null);
+}