[gtk/matthiasc/expression] More expression tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/matthiasc/expression] More expression tests
- Date: Thu, 28 Nov 2019 19:41:46 +0000 (UTC)
commit 6d8985a9397053ea5e677101941ce7ba554af90f
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Nov 28 14:40:34 2019 -0500
More expression tests
Test type mismatches, and the this pointer
during evaluation.
testsuite/gtk/expression.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
---
diff --git a/testsuite/gtk/expression.c b/testsuite/gtk/expression.c
index da452f1afd..67ea0e2405 100644
--- a/testsuite/gtk/expression.c
+++ b/testsuite/gtk/expression.c
@@ -239,6 +239,50 @@ test_nested (void)
gtk_expression_watch_unwatch (watch);
}
+static void
+test_type_mismatch (void)
+{
+ g_autoptr(GtkFilter) filter = NULL;
+ g_autoptr(GtkExpression) expr = NULL;
+ GValue value = G_VALUE_INIT;
+ gboolean res;
+
+ filter = gtk_any_filter_new ();
+
+ expr = gtk_property_expression_new (GTK_TYPE_STRING_FILTER, gtk_constant_expression_new
(GTK_TYPE_ANY_FILTER, filter), "search");
+
+ res = gtk_expression_evaluate (expr, NULL, &value);
+ g_assert_false (res);
+}
+
+static void
+test_this (void)
+{
+ g_autoptr(GtkFilter) filter = NULL;
+ g_autoptr(GtkFilter) filter2 = NULL;
+ g_autoptr(GtkExpression) expr = NULL;
+ GValue value = G_VALUE_INIT;
+ gboolean res;
+
+ expr = gtk_property_expression_new (GTK_TYPE_STRING_FILTER, NULL, "search");
+
+ filter = gtk_string_filter_new ();
+ gtk_string_filter_set_search (GTK_STRING_FILTER (filter), "word");
+
+ filter2 = gtk_string_filter_new ();
+ gtk_string_filter_set_search (GTK_STRING_FILTER (filter2), "sausage");
+
+ res = gtk_expression_evaluate (expr, filter, &value);
+ g_assert_true (res);
+ g_assert_cmpstr (g_value_get_string (&value), ==, "word");
+ g_value_unset (&value);
+
+ res = gtk_expression_evaluate (expr, filter2, &value);
+ g_assert_true (res);
+ g_assert_cmpstr (g_value_get_string (&value), ==, "sausage");
+ g_value_unset (&value);
+}
+
int
main (int argc, char *argv[])
{
@@ -250,6 +294,8 @@ main (int argc, char *argv[])
g_test_add_func ("/expression/constant", test_constant);
g_test_add_func ("/expression/object", test_object);
g_test_add_func ("/expression/nested", test_nested);
+ g_test_add_func ("/expression/type-mismatch", test_type_mismatch);
+ g_test_add_func ("/expression/this", test_this);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]