diff options
author | Thomas Holder <thomas.holder@schrodinger.com> | 2019-11-21 11:12:14 +0100 |
---|---|---|
committer | Thomas Holder <thomas.holder@schrodinger.com> | 2019-11-21 11:12:14 +0100 |
commit | c84f13cf14f2436524d143c44601b8a59ac07a11 (patch) | |
tree | 132a3f3375104d7ea0826afbdfe1644e6d8f86f4 /tests | |
parent | 9015d94eecc7e7e4c2f7a246455cc63a2361f8ed (diff) | |
download | glibmm-c84f13cf14f2436524d143c44601b8a59ac07a11.tar.gz |
Glib::Regex: Use UStringView
Fixes #66
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 2 | ||||
-rw-r--r-- | tests/glibmm_regex/main.cc | 28 |
2 files changed, 30 insertions, 0 deletions
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 <glibmm/regex.h> + +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; +} |