/*
Compile me with
cc test.c -Wall -Wextra -Werror `pkg-config --cflags --libs glib-2.0` -o test
*/
#include <glib.h>
int main() {
GRegex *regex;
GMatchInfo *match_info;
GError *error = NULL;
gboolean matched;
regex = g_regex_new("^(a)?(b)(c)?$", 0, 0, &error);
g_assert(regex != NULL);
g_assert_no_error(error);
g_assert_cmpint(g_regex_get_capture_count(regex), ==, 3);
matched = g_regex_match_full(regex, "b", -1, 0, 0, &match_info, &error);
g_assert(matched);
g_assert_no_error(error);
g_assert_cmpstr(g_match_info_fetch(match_info, 1), ==, "");
g_assert_cmpstr(g_match_info_fetch(match_info, 2), ==, "b");
g_assert_cmpstr(g_match_info_fetch(match_info, 3), ==, "");
return 0;
}