diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 15:18:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 15:18:46 +0000 |
commit | 56294d30a82ec2da6f9ce399740c1ef65a9ddef4 (patch) | |
tree | bbe3823e41495d026ba8edc6eeaef166edb7e2a2 /src/gs-self-test.c | |
parent | Initial commit. (diff) | |
download | gnome-software-56294d30a82ec2da6f9ce399740c1ef65a9ddef4.tar.xz gnome-software-56294d30a82ec2da6f9ce399740c1ef65a9ddef4.zip |
Adding upstream version 3.38.1.upstream/3.38.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/gs-self-test.c')
-rw-r--r-- | src/gs-self-test.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/gs-self-test.c b/src/gs-self-test.c new file mode 100644 index 0000000..43d94c5 --- /dev/null +++ b/src/gs-self-test.c @@ -0,0 +1,61 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * vi:set noexpandtab tabstop=8 shiftwidth=8: + * + * Copyright (C) 2017 Richard Hughes <richard@hughsie.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include "config.h" + +#include "gnome-software-private.h" + +#include "gs-content-rating.h" +#include "gs-css.h" +#include "gs-test.h" + +static void +gs_css_func (void) +{ + const gchar *tmp; + gboolean ret; + g_autoptr(GError) error = NULL; + g_autoptr(GsCss) css = gs_css_new (); + + /* no IDs */ + ret = gs_css_parse (css, "border: 0;", &error); + g_assert_no_error (error); + g_assert (ret); + tmp = gs_css_get_markup_for_id (css, "tile"); + g_assert_cmpstr (tmp, ==, "border: 0;"); + + /* with IDs */ + ret = gs_css_parse (css, "#tile2{\nborder: 0;}\n#name {color: white;\n}", &error); + g_assert_no_error (error); + g_assert (ret); + tmp = gs_css_get_markup_for_id (css, "NotGoingToExist"); + g_assert_cmpstr (tmp, ==, NULL); + tmp = gs_css_get_markup_for_id (css, "tile2"); + g_assert_cmpstr (tmp, ==, "border: 0;"); + tmp = gs_css_get_markup_for_id (css, "name"); + g_assert_cmpstr (tmp, ==, "color: white;"); +} + +int +main (int argc, char **argv) +{ + g_test_init (&argc, &argv, +#if GLIB_CHECK_VERSION(2, 60, 0) + G_TEST_OPTION_ISOLATE_DIRS, +#endif + NULL); + g_setenv ("G_MESSAGES_DEBUG", "all", TRUE); + + /* only critical and error are fatal */ + g_log_set_fatal_mask (NULL, G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL); + + /* tests go here */ + g_test_add_func ("/gnome-software/src/css", gs_css_func); + + return g_test_run (); +} |