From c84f13cf14f2436524d143c44601b8a59ac07a11 Mon Sep 17 00:00:00 2001 From: Thomas Holder Date: Thu, 21 Nov 2019 11:12:14 +0100 Subject: Glib::Regex: Use UStringView Fixes #66 --- tests/Makefile.am | 2 ++ tests/glibmm_regex/main.cc | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 tests/glibmm_regex/main.cc (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 3905c52f..68effc10 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -39,6 +39,7 @@ check_PROGRAMS = \ glibmm_object_move/test \ glibmm_objectbase/test \ glibmm_objectbase_move/test \ + glibmm_regex/test \ glibmm_ustring_compose/test \ glibmm_ustring_format/test \ glibmm_ustring_sprintf/test \ @@ -117,6 +118,7 @@ glibmm_objectbase_move_test_SOURCES = glibmm_objectbase_move/main.cc \ glibmm_ustring_compose_test_SOURCES = glibmm_ustring_compose/main.cc glibmm_ustring_format_test_SOURCES = glibmm_ustring_format/main.cc glibmm_ustring_sprintf_test_SOURCES = glibmm_ustring_sprintf/main.cc +glibmm_regex_test_SOURCES = glibmm_regex/main.cc glibmm_value_test_SOURCES = glibmm_value/main.cc glibmm_variant_test_SOURCES = glibmm_variant/main.cc glibmm_vector_test_SOURCES = glibmm_vector/main.cc diff --git a/tests/glibmm_regex/main.cc b/tests/glibmm_regex/main.cc new file mode 100644 index 00000000..1b049d28 --- /dev/null +++ b/tests/glibmm_regex/main.cc @@ -0,0 +1,28 @@ +#include + +static void +test_match_string_literal() +{ + auto regex = Glib::Regex::create("(\\S+)"); + Glib::MatchInfo matchInfo; + + regex->match("this is not a Glib::ustring const reference", matchInfo); + + for (const char* s : { "this", "is", "not", "a", "Glib::ustring", "const", "reference" }) + { + g_assert_true(matchInfo.matches()); + g_assert_true(matchInfo.fetch(1) == s); + matchInfo.next(); + } + + g_assert_false(matchInfo.matches()); +} + +int +main() +{ + // https://gitlab.gnome.org/GNOME/glibmm/issues/66 + test_match_string_literal(); + + return EXIT_SUCCESS; +} -- cgit v1.2.1