[libdazzle] tests: add simple pattern spec test
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] tests: add simple pattern spec test
- Date: Sun, 3 Sep 2017 21:21:58 +0000 (UTC)
commit 288d1fc995b108c64f2961b23d2203fcf690b68e
Author: Christian Hergert <chergert redhat com>
Date: Sun Sep 3 14:21:01 2017 -0700
tests: add simple pattern spec test
tests/meson.build | 7 +++++
tests/test-pattern-spec.c | 56 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 0 deletions(-)
---
diff --git a/tests/meson.build b/tests/meson.build
index f591599..17d32cb 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -336,4 +336,11 @@ test_util = executable('test-util', 'test-util.c',
)
test('test-util', test_util, env: test_env)
+test_pattern_spec = executable('test-pattern-spec', 'test-pattern-spec.c',
+ c_args: test_cflags,
+ link_args: test_link_args,
+ dependencies: libdazzle_deps + [libdazzle_dep],
+)
+test('test-pattern-spec', test_pattern_spec, env: test_env)
+
endif
diff --git a/tests/test-pattern-spec.c b/tests/test-pattern-spec.c
new file mode 100644
index 0000000..fdb4724
--- /dev/null
+++ b/tests/test-pattern-spec.c
@@ -0,0 +1,56 @@
+/* test-pattern-spec.c
+ *
+ * Copyright (C) 2017 Christian Hergert <chergert redhat com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <dazzle.h>
+
+static void
+test_basic (void)
+{
+ static const struct {
+ const gchar *needle;
+ const gchar *haystack;
+ gboolean result;
+ } tests[] = {
+ { "blue", "red blue purple pink green black cyan", TRUE },
+ { "Blue", "red blue purple pink green black cyan", FALSE },
+ { "blue", "red Blue purple pink green black cyan", TRUE },
+ { "DzlPatternSpec", "DzlPatternSpec_autoptr", TRUE },
+ { "dzlpattern", "DzlPatternSpec_autoptr", TRUE },
+ { "dzlpattern", "dzl_pattern_spec", FALSE },
+ { "dzl pattern", "dzl_pattern_spec", TRUE },
+ };
+
+ for (guint i = 0; i < G_N_ELEMENTS (tests); i++)
+ {
+ g_autoptr(DzlPatternSpec) spec = NULL;
+ gboolean r;
+
+ spec = dzl_pattern_spec_new (tests[i].needle);
+ r = dzl_pattern_spec_match (spec, tests[i].haystack);
+ g_assert_cmpint (r, ==, tests[i].result);
+ }
+}
+
+gint
+main (gint argc,
+ gchar *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+ g_test_add_func ("/Dazzle/PatternSpec/basic", test_basic);
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]