Add a meson build system
The unit tests are currently broken and i'm not sure how they're working under
cmake right now, but I'll figure that out later.
--- a/.hgignore Sat Mar 04 10:36:35 2023 -0600
+++ b/.hgignore Sat Mar 04 11:27:30 2023 -0600
@@ -1,26 +1,4 @@
-^doc/gplate/gplate-un(declared|documented|used)\.txt$
-^doc/gplate/gplate-decl(-list)?\.txt$
-^doc/gplate/gplate\.(args|hierarchy|interfaces|prerequisites|signals)$
-^doc/gplate/overview\.sgml$
-^gplate/configs/.+\.(dot|png)$
-^gplate/libgplate\.dylib$
-tests/test-([a-zA-Z0-9-]+)(\.exe|\.log)?$
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/gplate.h.in Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,38 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#ifndef __GI_SCANNER__ /* hide this bit from g-ir-scanner */ +# ifdef GPLATE_COMPILATION +# error "gplate source files should not be including gplate.h" +# endif /* GPLATE_COMPILATION */ +#endif /* __GI_SCANNER__ */ +#ifndef GPLATE_GLOBAL_HEADER_INSIDE +# define GPLATE_GLOBAL_HEADER_INSIDE +#endif /* GPLATE_GLOBAL_HEADER_INSIDE */ +#undef GPLATE_GLOBAL_HEADER_INSIDE +#endif /* GPLATE_PURPLE_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/meson.build Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,147 @@
+ 'functions/gplate-for-function.c', + 'functions/gplate-include-function.c', + 'functions/gplate-noop-function.c', + 'functions/gplate-print-function.c', + 'functions/gplate-text-function.c', + 'tags/gplate-code-tag.c', + 'tags/gplate-comment-tag.c', + 'tags/gplate-text-tag.c', + 'tags/gplate-variable-tag.c', + 'variables/gplate-dictionary-variable.c', + 'variables/gplate-directory-variable.c', + 'variables/gplate-file-variable.c', + 'variables/gplate-object-variable.c', + 'functions/gplate-for-function.h', + 'functions/gplate-include-function.h', + 'functions/gplate-noop-function.h', + 'functions/gplate-print-function.h', + 'functions/gplate-text-function.h', + 'tags/gplate-code-tag.h', + 'tags/gplate-comment-tag.h', + 'tags/gplate-text-tag.h', + 'tags/gplate-variable-tag.h', + 'variables/gplate-dictionary-variable.h', + 'variables/gplate-directory-variable.h', + 'variables/gplate-file-variable.h', + 'variables/gplate-object-variable.h', +GPLATE_BUILT_SOURCES = [] +GPLATE_BUILT_HEADERS = [] +GPLATE_DEPENDENCIES = [GLIB, GOBJECT] +gplate_filebase = 'gplate-1' +gplate_include_base = gplate_filebase / 'gplate' +GPLATE_ENUMS = gnome.mkenums_simple('gplateenums', + sources : GPLATE_ENUM_HEADERS, + install_dir : get_option('includedir') / gplate_include_base) +GPLATE_BUILT_SOURCES += GPLATE_ENUMS[0] +GPLATE_BUILT_HEADERS += GPLATE_ENUMS[1] +foreach header : GPLATE_HEADERS + ['gplateenums.h'] + GPLATE_H_INCLUDES += '#include <gplate/@0@>'.format(header) +gplate_h_conf = configuration_data() +gplate_h_conf.set('GPLATE_H_INCLUDES', '\n'.join(GPLATE_H_INCLUDES)) +gplate_h = configure_file( + configuration : gplate_h_conf, + install_dir : get_option('includedir') / gplate_filebase) +GPLATE_BUILT_HEADERS += gplate_h +#gplate_resources = gnome.compile_resources('gplateresources', +# 'resources/gplate.gresource.xml', +# source_dir : 'resources', +#GPLATE_BUILT_SOURCES += gplate_resources[0] +#GPLATE_BUILT_HEADERS += gplate_resources[1] +gplate_inc = include_directories('.') +GPLATE_ALL_SOURCES = GPLATE_SOURCES + GPLATE_HEADERS + GPLATE_BUILT_SOURCES + GPLATE_BUILT_HEADERS + '-DGPLATE_COMPILATION', + '-DGPLATE_RESOURCE_PATH="/org/imfreedom/keep/gplate/gplate"', +libgplate = library('gplate', + dependencies : GPLATE_DEPENDENCIES, + c_args : GPLATE_CFLAGS, + version : GPLATE_VERSION, + include_directories : [toplevel_inc, gplate_inc], +gplate_dep = declare_dependency( + # Ensure headers built before any dependencies: + sources : GPLATE_BUILT_HEADERS, + include_directories : [toplevel_inc, gplate_inc], + dependencies : GPLATE_DEPENDENCIES) +meson.override_dependency(gplate_filebase, gplate_dep) +install_headers(GPLATE_HEADERS, subdir : gplate_include_base) + description : 'gobject based templating library', + version : meson.project_version(), + filebase : gplate_filebase, + subdirs : [gplate_filebase], + requires : [GLIB, GOBJECT]) +if get_option('introspection') + gplate_gir = gnome.generate_gir(libgplate, + sources : GPLATE_ALL_SOURCES, + includes : ['GLib-2.0', 'GObject-2.0'], + symbol_prefix : 'gplate', + identifier_prefix : 'GPlate', + export_packages : gplate_filebase, + extra_args : ['-DGPLATE_COMPILATION', '--quiet']) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/reference/gplate.toml.in Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,38 @@
+version = "@GPLATE_VERSION@" +browse_url = "https://keep.imfreedom.org/gplate/gplate/" +repository_url = "https://keep.imfreedom.org/gplate/gplate/" +website_url = "https://keep.imfreedom.org/gplate/gplate/" +authors = "GPlate Developers" +license = "LGPL-2.1-or-later" +description = "GPlate GObject Template Library" +dependencies = [ "GLib-2.0", "GObject-2.0" ] + [dependencies."GLib-2.0"] + description = "General-purpose, portable utility library." + docs_url = "https://docs.gtk.org/glib/" + [dependencies."GObject-2.0"] + description = "The base type system library" + docs_url = "https://docs.gtk.org/gobject/" +show_index_summary = true +show_class_hierarchy = true +base_url = "https://keep.imfreedom.org/gplate/gplate/file/default/" +# The same order will be used when generating the index +urlmap_file = "urlmap.js" --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/reference/meson.build Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,31 @@
+gplate_doc_content_files = [] + gplate_toml = configure_file( + input : 'gplate.toml.in', + output : 'gplate.toml', + configuration : version_conf, + install_dir : docs_dir / 'gplate', + gplate_doc = custom_target('gplate-doc', + input : [ gplate_toml, gplate_gir[0] ], + '--output-dir=@OUTPUT@', + '--content-dir=@0@'.format(meson.current_source_dir()), + depend_files : [ gplate_doc_content_files ], + build_by_default : true, + install_dir : docs_dir, --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/reference/urlmap.js Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,8 @@
+// SPDX-FileCopyrightText: 2021 GNOME Foundation +// SPDX-License-Identifier: LGPL-2.1-or-later +// A map between namespaces and base URLs for their online documentation + [ 'GLib', 'https://docs.gtk.org/glib/' ], + [ 'GObject', 'https://docs.gtk.org/gobject/' ], --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/resources/gplate.gresource.xml Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?> + <gresource prefix="/org/imfreedom/keep/gplate/gplate/"> --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/CMakeLists.txt Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,29 @@
+ -DTEST_DIR="${CMAKE_CURRENT_SOURCE_DIR}" +add_subdirectory(functions) +add_subdirectory(variables) +add_executable(test-gplate test-gplate.c) +target_link_libraries(test-gplate +############################################################################### +############################################################################### +set(GTESTER_TESTS "${TESTS}") +set(GTESTER_LOG "testgplate.log") +add_custom_target(tests ALL + COMMAND ${GTESTER} -k --verbose -o ${GTESTER_LOG} test-gplate --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/functions/CMakeLists.txt Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,15 @@
+set(TEST_GPLATE_FUNCTIONS_HEADERS + test-gplate-functions.h +set(TEST_GPLATE_FUNCTIONS_SOURCES + test-gplate-functions.c + test-gplate-for-function.c + test-gplate-include-function.c +add_library(test-gplate-functions STATIC + ${TEST_GPLATE_FUNCTIONS_HEADERS} + ${TEST_GPLATE_FUNCTIONS_SOURCES} --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/functions/test-gplate-for-function.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,181 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +#include <gplate/variables/gplate-dictionary-variable.h> +/****************************************************************************** + *****************************************************************************/ +} TestGPlateForFunctionData; + GPlateTemplate *template; + const gchar *template_string; + TestGPlateForFunctionData *data; +} TestGPlateForFunctionFixture; +/****************************************************************************** + *****************************************************************************/ +test_gplate_for_function_setup(TestGPlateForFunctionFixture *fixture, + fixture->template = gplate_template_new(); + fixture->dict = gplate_dictionary_variable_new("list"); + gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template), +test_gplate_for_function_teardown(TestGPlateForFunctionFixture *fixture, + g_object_unref(fixture->template); + fixture->template = NULL; + g_object_unref(fixture->dict); + g_free(fixture->actual); + fixture->actual = NULL; + fixture->expected = NULL; + g_error_free(fixture->error); +/****************************************************************************** + *****************************************************************************/ +test_gplate_for_function(TestGPlateForFunctionFixture *fixture) { + /* add the variables */ + for(i = 0; fixture->data[i].name; i++) { + gplate_collection_add_string(fixture->dict, + fixture->data[i].value); + fixture->actual = gplate_template_render(fixture->template, + fixture->template_string, + g_assert(fixture->error == NULL); + g_assert_cmpstr(fixture->expected, ==, fixture->actual); +/****************************************************************************** + *****************************************************************************/ +test_gplate_for_function_zero_elements(TestGPlateForFunctionFixture *fixture, + gconstpointer user_data) + TestGPlateForFunctionData data[] = { + fixture->template_string = "{% for in in line %}{{ i }}{% endfor %}"; + fixture->expected = ""; + test_gplate_for_function(fixture); +test_gplate_for_function_one_element(TestGPlateForFunctionFixture *fixture, + gconstpointer user_data) + TestGPlateForFunctionData data[] = { + fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}"; + fixture->expected = "1"; + test_gplate_for_function(fixture); +test_gplate_for_function_two_elements(TestGPlateForFunctionFixture *fixture, + gconstpointer user_data) + TestGPlateForFunctionData data[] = { + fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}"; + fixture->expected = "AB"; + test_gplate_for_function(fixture); +/****************************************************************************** + *****************************************************************************/ +test_gplate_for_function_add_tests(void) { + g_test_add("/functions/foo/zero_elements", + TestGPlateForFunctionFixture, + test_gplate_for_function_setup, + test_gplate_for_function_zero_elements, + test_gplate_for_function_teardown); + g_test_add("/functions/foo/one_element", + TestGPlateForFunctionFixture, + test_gplate_for_function_setup, + test_gplate_for_function_one_element, + test_gplate_for_function_teardown); + g_test_add("/functions/foo/two_elements", + TestGPlateForFunctionFixture, + test_gplate_for_function_setup, + test_gplate_for_function_two_elements, + test_gplate_for_function_teardown); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/functions/test-gplate-functions.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,29 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include "test-gplate-functions.h" +/****************************************************************************** + *****************************************************************************/ +test_gplate_functions_add_tests(void) { + test_gplate_for_function_add_tests(); + test_gplate_include_function_add_tests(); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/functions/test-gplate-functions.h Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,36 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#ifndef TEST_GPLATE_FUNCTIONS_H +#define TEST_GPLATE_FUNCTIONS_H +#include <gplate/gplate.h> +void test_gplate_functions_add_tests(void); +/* external prototypes */ +void test_gplate_for_function_add_tests(void); +void test_gplate_include_function_add_tests(void); +#endif /* TEST_GPLATE_FUNCTIONS_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/functions/test-gplate-include-function.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,132 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +/****************************************************************************** + *****************************************************************************/ + GPlateTemplate *template; + const gchar *template_string; +} TestGPlateIncludeFunctionFixture; +/****************************************************************************** + *****************************************************************************/ +test_gplate_include_function_setup(TestGPlateIncludeFunctionFixture *fixture, + fixture->template = gplate_template_new(); +test_gplate_include_function_teardown(TestGPlateIncludeFunctionFixture *fixture, + g_object_unref(fixture->template); + fixture->template = NULL; + g_free(fixture->actual); + fixture->actual = NULL; + fixture->expected = NULL; + g_error_free(fixture->error); +/****************************************************************************** + *****************************************************************************/ +test_gplate_include_function_simple(TestGPlateIncludeFunctionFixture *fixture, + fixture->expected = "including\nincluded!\n\ndone\n\n"; + path = g_build_filename(TEST_DIR, "templates", "simple.gplate", NULL); + fixture->actual = gplate_template_render_file(fixture->template, + g_assert(fixture->error == NULL); + g_assert_cmpstr(fixture->expected, ==, fixture->actual); +test_gplate_include_function_double(TestGPlateIncludeFunctionFixture *fixture, + path = g_build_filename(TEST_DIR, "templates", "html.gplate", NULL); + fixture->actual = gplate_template_render_file(fixture->template, + g_assert(fixture->error == NULL); + g_assert_cmpstr(fixture->expected, ==, fixture->actual); +/****************************************************************************** + *****************************************************************************/ +test_gplate_include_function_add_tests(void) { + g_test_add("/functions/include/simple", + TestGPlateIncludeFunctionFixture, + test_gplate_include_function_setup, + test_gplate_include_function_simple, + test_gplate_include_function_teardown); + g_test_add("/functions/include/double", + TestGPlateIncludeFunctionFixture, + test_gplate_include_function_setup, + test_gplate_include_function_double, + test_gplate_include_function_teardown); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/meson.build Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,14 @@
+ 'gplate-collection-interface', + 'gplate-utility-functions', +foreach program : PROGRAMS + e = executable(f'test-@program@', f'test-@program@.c', + dependencies : [gplate_dep, GLIB], --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/tags/CMakeLists.txt Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,16 @@
+set(TEST_GPLATE_TAGS_HEADERS +set(TEST_GPLATE_TAGS_SOURCES + test-gplate-comment-tag.c + test-gplate-variable-tag.c +add_library(test-gplate-tags STATIC + ${TEST_GPLATE_TAGS_HEADERS} + ${TEST_GPLATE_TAGS_SOURCES} --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/tags/test-gplate-comment-tag.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,74 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +#include "test-gplate-tag.h" +/****************************************************************************** + *****************************************************************************/ +test_gplate_comment_tag_empty(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, "{##}", ""); +test_gplate_comment_tag_whitespace(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, "{# #}", ""); + test_gplate_tag_output(fixture, data, "{#\t#}", ""); + test_gplate_tag_output(fixture, data, "{#\n#}", ""); + test_gplate_tag_output(fixture, data, "{#\r#}", ""); + test_gplate_tag_output(fixture, data, "{#\r\n#}", ""); + test_gplate_tag_output(fixture, data, "{#\n\r#}", ""); +test_gplate_comment_tag_simple(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, "{# foo#}", ""); + test_gplate_tag_output(fixture, data, "{#foo #}", ""); + test_gplate_tag_output(fixture, data, "{#\tfoo#}", ""); + test_gplate_tag_output(fixture, data, "{#foo\t#}", ""); + test_gplate_tag_output(fixture, data, "{#\nfoo#}", ""); + test_gplate_tag_output(fixture, data, "{#foo\n#}", ""); + test_gplate_tag_output(fixture, data, "{#\rfoo#}", ""); + test_gplate_tag_output(fixture, data, "{#foo\r#}", ""); + test_gplate_tag_output(fixture, data, "{#\r\nfoo#}", ""); + test_gplate_tag_output(fixture, data, "{#foo\r\n#}", ""); +/****************************************************************************** + *****************************************************************************/ +test_gplate_comment_tag_add_tests(void) { + test_gplate_tag_add("/tags/comment/empty", + test_gplate_comment_tag_empty); + test_gplate_tag_add("/tags/comment/whitespace", + test_gplate_comment_tag_whitespace); + test_gplate_tag_add("/tags/comment/simple", + test_gplate_comment_tag_simple); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/tags/test-gplate-tag.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,73 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include "test-gplate-tag.h" +/****************************************************************************** + *****************************************************************************/ +test_gplate_tag_setup(TestGPlateTagFixture *fixture, gconstpointer data) { + gplate_config_load_default(); + fixture->template = gplate_template_new(); +test_gplate_tag_teardown(TestGPlateTagFixture *fixture, gconstpointer data) { + g_object_unref(fixture->template); + fixture->template = NULL; + g_error_free(fixture->error); + g_free(fixture->actual); + fixture->actual = NULL; +/****************************************************************************** + *****************************************************************************/ +test_gplate_tag_output(TestGPlateTagFixture *fixture, + const gchar *template_string, + fixture->template_string = template_string; + fixture->expected = expected; + fixture->actual = gplate_template_render(fixture->template, + fixture->template_string, + g_assert(fixture->error == NULL); + g_assert_cmpstr(fixture->expected, ==, fixture->actual); +/****************************************************************************** + *****************************************************************************/ +test_gplate_tag_add_tests(void) { + test_gplate_text_tag_add_tests(); + test_gplate_variable_tag_add_tests(); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/tags/test-gplate-tag.h Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,58 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#ifndef TEST_GPLATE_TAG_H +#define TEST_GPLATE_TAG_H +#include <gplate/gplate.h> +#define test_gplate_tag_add(path, func) \ + g_test_add((path), TestGPlateTagFixture, NULL, test_gplate_tag_setup, (func), test_gplate_tag_teardown) +typedef struct _TestGPlateTagFixture TestGPlateTagFixture; +typedef void (*TestGPlateTagFixtureFunc)(TestGPlateTagFixture *fixture, gconstpointer data); +struct _TestGPlateTagFixture { + GPlateTemplate *template; + const gchar *template_string; +void test_gplate_tag_setup(TestGPlateTagFixture *fixture, gconstpointer data); +void test_gplate_tag_teardown(TestGPlateTagFixture *fixture, gconstpointer data); +void test_gplate_tag_output(TestGPlateTagFixture *fixture, gconstpointer data, const gchar *template_string, const gchar *expected); +void test_gplate_tag_add_tests(void); +/* external prototypes */ +void test_gplate_comment_tag_add_tests(void); +void test_gplate_text_tag_add_tests(void); +void test_gplate_variable_tag_add_tests(void); +#endif /* TEST_GPLATE_TAG_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/tags/test-gplate-text-tag.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,63 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +#include "test-gplate-tag.h" +/****************************************************************************** + *****************************************************************************/ +test_gplate_text_tag_syntax_plain(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, + "simple template", "simple template"); +test_gplate_text_tag_syntax_keywords(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, + "extends if else endif for endfor", + "extends if else endif for endfor"); +test_gplate_text_tag_syntax_keywords_case_sensitive(TestGPlateTagFixture *fixture, + test_gplate_tag_output(fixture, data, + "EXteNds iF eLse enDif fOr enDFor", + "EXteNds iF eLse enDif fOr enDFor"); +test_gplate_text_tag_add_tests(void) { + test_gplate_tag_add("/tags/text/plain", + test_gplate_text_tag_syntax_plain); + test_gplate_tag_add("/tags/text/keywords", + test_gplate_text_tag_syntax_keywords); + test_gplate_tag_add("/tags/text/keywords_case_sensitive", + test_gplate_text_tag_syntax_keywords_case_sensitive); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/tags/test-gplate-variable-tag.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,232 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +#include "test-gplate-tag.h" +/****************************************************************************** + *****************************************************************************/ +test_gplate_variable_tag(TestGPlateTagFixture *fixture, gconstpointer data, + const gchar *template_string, const gchar *expected, + const gchar *name = NULL, *value = NULL; + va_start(vargs, expected); + while((name = va_arg(vargs, const gchar *))) { + value = va_arg(vargs, const gchar *); + gplate_collection_add_string(GPLATE_COLLECTION(fixture->template), + test_gplate_tag_output(fixture, data, template_string, expected); +/****************************************************************************** + *****************************************************************************/ +test_gplate_variable_tag_single(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, +test_gplate_variable_tag_double(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "{{ foo }}{{ bar }}", "foobar", +test_gplate_variable_tag_tripple(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz", +test_gplate_variable_tag_newline_prefix(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, +test_gplate_variable_tag_newline_suffix(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, +test_gplate_variable_tag_newline_wrapped(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, +test_gplate_variable_tag_single_quotes(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "foo '{{ bar }}' baz", "foo 'bar' baz", +test_gplate_variable_tag_double_quotes(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "foo \"{{ bar }}\" baz", "foo \"bar\" baz", +test_gplate_variable_tag_mixed_quotes(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "foo \"{{ bar }}' baz", "foo \"bar' baz", + test_gplate_variable_tag(fixture, data, + "foo '{{ bar }}\" baz", "foo 'bar\" baz", +test_gplate_variable_tag_two_vars_one_block(TestGPlateTagFixture *fixture, + test_gplate_variable_tag(fixture, data, + "one {{ two five }} three", +test_gplate_variable_tag_nested_single(TestGPlateTagFixture *fixture, + GPlateVariable *dict = gplate_dictionary_variable_new("foo"); + gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template), + gplate_collection_add_string(GPLATE_COLLECTION(dict), + test_gplate_tag_output(fixture, data, "{{ foo.bar }}", "baz"); +test_gplate_variable_tag_nested_double(TestGPlateTagFixture *fixture, + GPlateVariable *dict1 = gplate_dictionary_variable_new("foo"); + GPlateVariable *dict2 = gplate_dictionary_variable_new("bar"); + gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template), + gplate_collection_add_variable(GPLATE_COLLECTION(dict1), dict2); + gplate_collection_add_string(GPLATE_COLLECTION(dict2), + test_gplate_tag_output(fixture, data, "{{ foo.bar.baz }}", "42"); +/****************************************************************************** + *****************************************************************************/ +test_gplate_variable_tag_add_tests(void) { + test_gplate_tag_add("/tags/variable/single", + test_gplate_variable_tag_single); + test_gplate_tag_add("/tags/variable/double", + test_gplate_variable_tag_double); + test_gplate_tag_add("/tags/variable/tripple", + test_gplate_variable_tag_tripple); + test_gplate_tag_add("/tags/variable/newline_prefix", + test_gplate_variable_tag_newline_prefix); + test_gplate_tag_add("/tags/variable/newline_suffix", + test_gplate_variable_tag_newline_suffix); + test_gplate_tag_add("/tags/variable/newline_wrapped", + test_gplate_variable_tag_newline_wrapped); + test_gplate_tag_add("/tags/variable/quotes/single", + test_gplate_variable_tag_single_quotes); + test_gplate_tag_add("/tags/variable/quotes/double", + test_gplate_variable_tag_double_quotes); + test_gplate_tag_add("/tags/variable/quotes/mixed", + test_gplate_variable_tag_mixed_quotes); + test_gplate_tag_add("/tags/variable/two_vars_one_block", + test_gplate_variable_tag_two_vars_one_block); + test_gplate_tag_add("/tags/variable/nested/single", + test_gplate_variable_tag_nested_single); + test_gplate_tag_add("/tags/variable/nested/double", + test_gplate_variable_tag_nested_double); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/templates/footer.gplate Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,2 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/templates/header.gplate Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,5 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/templates/html.gplate Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,1 @@
+{% include "header.gplate" %}in the body{% include "footer.gplate" %} --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/templates/simple-include.gplate Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,1 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/templates/simple.gplate Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,4 @@
+{% include "simple-include.gplate" %} --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/test-collection.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,29 @@
+#include "test-collection.h" +test_collection_lookup(GPlateCollection *collection, const gchar *name, + v = gplate_collection_lookup(collection, name); + test_string(expected, v); +test_collection_lookup_int(GPlateCollection *collection, const gchar *name, + v = gplate_collection_lookup(collection, name); + e = g_strdup_printf("%d", expected); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/test-dictionary-variable.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,255 @@
+#endif /* HAVE_CONFIG_H */ +#include <gplate/gplate.h> +#include "test-collection.h" +#include "test-object.h" +/****************************************************************************** + *****************************************************************************/ +/****************************************************************************** + *****************************************************************************/ +static GPlateVariable *dict = NULL; +static GPlateIterator *iter = NULL; +/****************************************************************************** + *****************************************************************************/ +iterator_test(VariableData *vd) { + /* add all the values and make sure they got entered correctly */ + for(i = 0, count = 0; vd[i].name; i++, count++) { + gplate_collection_add_string(dict, vd[i].name, vd[i].value); + test_collection_lookup(GPLATE_COLLECTION(dict), + vd[i].name, vd[i].value); + iter = gplate_collection_get_iterator(GPLATE_COLLECTION(dict)); + while(gplate_iterator_has_next(iter)) { + GPlateVariable *var = gplate_iterator_next(iter); + const gchar *value = gplate_variable_get_value(var); + test_string(vd[i++].value, value); + fail_unless(i == count, "Iterated over %d/%d elements.", i, count); +/****************************************************************************** + *****************************************************************************/ +collection_interface_setup(void) { + dict = gplate_dictionary_variable_new("dict"); +collection_interface_teardown(void) { + g_object_unref(G_OBJECT(dict)); + g_object_unref(G_OBJECT(iter)); +/****************************************************************************** + * Object Hierarchy Tests + *****************************************************************************/ +START_TEST(test_dictionary_hierarchy_type) + test_object_is_a(G_OBJECT(dict), GPLATE_TYPE_DICTIONARY_VARIABLE); +START_TEST(test_dictionary_hierarchy_parent) + test_object_is_a(G_OBJECT(dict), GPLATE_TYPE_VARIABLE); +START_TEST(test_dictionary_hierarchy_collection) + test_object_is_a(G_OBJECT(dict), GPLATE_TYPE_COLLECTION); +/****************************************************************************** + * Collection Interface Tests + *****************************************************************************/ +START_TEST(test_dictionary_add_string_null) + gplate_collection_add_string(dict, "null", NULL); + test_collection_lookup(GPLATE_COLLECTION(dict), "null", NULL); +START_TEST(test_dictionary_add_string_empty) + gplate_collection_add_string(dict, "empty", ""); + test_collection_lookup(GPLATE_COLLECTION(dict), "empty", ""); +START_TEST(test_dictionary_add_string) + gplate_collection_add_string(dict, "string", "string"); + test_collection_lookup(GPLATE_COLLECTION(dict), "string", "string"); +START_TEST(test_dictionary_add_boolean_true) + gplate_collection_add_boolean(dict, "true", TRUE); + test_collection_lookup(GPLATE_COLLECTION(dict), "true", "TRUE"); +START_TEST(test_dictionary_add_boolean_false) + gplate_collection_add_boolean(dict, "false", FALSE); + test_collection_lookup(GPLATE_COLLECTION(dict), "false", "FALSE"); +START_TEST(test_dictionary_add_float_positive) + gplate_collection_add_float(dict, "pi", 3.14f); + test_collection_lookup(GPLATE_COLLECTION(dict), "pi", "3.140000"); +START_TEST(test_dictionary_add_float_positive_whole) + gplate_collection_add_float(dict, "three", 3.0f); + test_collection_lookup(GPLATE_COLLECTION(dict), "three", "3.000000"); +START_TEST(test_dictionary_add_float_negative) + gplate_collection_add_float(dict, "negativepi", -3.14f); + test_collection_lookup(GPLATE_COLLECTION(dict), "negativepi", "-3.140000"); +START_TEST(test_dictionary_add_float_negative_whole) + gplate_collection_add_float(dict, "negativethree", -3.0f); + test_collection_lookup(GPLATE_COLLECTION(dict), "negativethree", "-3.000000"); +START_TEST(test_dictionary_add_double_positive) + gplate_collection_add_double(dict, "e", 2.71); + test_collection_lookup(GPLATE_COLLECTION(dict), "e", "2.71"); +START_TEST(test_dictionary_add_double_positive_whole) + gplate_collection_add_double(dict, "two", 2.0); + test_collection_lookup(GPLATE_COLLECTION(dict), "two", "2"); +START_TEST(test_dictionary_add_double_negative) + gplate_collection_add_double(dict, "negativee", -2.71); + test_collection_lookup(GPLATE_COLLECTION(dict), "negativee", "-2.71"); +START_TEST(test_dictionary_add_double_negative_whole) + gplate_collection_add_double(dict, "negativetwo", -2.0); + test_collection_lookup(GPLATE_COLLECTION(dict), "negativetwo", "-2"); +START_TEST(test_dictionary_nested) + GPlateVariable *nested = gplate_dictionary_variable_new("nested"); + gplate_collection_add_variable(GPLATE_COLLECTION(dict), nested); + gplate_collection_add_string(GPLATE_COLLECTION(nested), "nestedstring", + test_collection_lookup(GPLATE_COLLECTION(dict), "nested.nestedstring", +START_TEST(test_dictionary_iterator_empty) +START_TEST(test_dictionary_iterator_one_element) +START_TEST(test_dictionary_iterator_many_elements_sorted) +/****************************************************************************** + *****************************************************************************/ +dictionary_variable_suite(void) { + Suite *s = suite_create("Dictionary Variable Suite"); + tc = tcase_create("Object hierarchy"); + tcase_add_checked_fixture(tc, collection_interface_setup, + collection_interface_teardown); + tcase_add_test(tc, test_dictionary_hierarchy_type); + tcase_add_test(tc, test_dictionary_hierarchy_parent); + tcase_add_test(tc, test_dictionary_hierarchy_collection); + suite_add_tcase(s, tc); + /* collection interface */ + tc = tcase_create("Collection Interface"); + tcase_add_checked_fixture(tc, collection_interface_setup, + collection_interface_teardown); + tcase_add_test(tc, test_dictionary_add_string_null); + tcase_add_test(tc, test_dictionary_add_string_empty); + tcase_add_test(tc, test_dictionary_add_string); + tcase_add_test(tc, test_dictionary_add_boolean_true); + tcase_add_test(tc, test_dictionary_add_boolean_false); + tcase_add_test(tc, test_dictionary_add_float_positive); + tcase_add_test(tc, test_dictionary_add_float_positive_whole); + tcase_add_test(tc, test_dictionary_add_float_negative); + tcase_add_test(tc, test_dictionary_add_float_negative_whole); + tcase_add_test(tc, test_dictionary_add_double_positive); + tcase_add_test(tc, test_dictionary_add_double_positive_whole); + tcase_add_test(tc, test_dictionary_add_double_negative); + tcase_add_test(tc, test_dictionary_add_double_negative_whole); + tcase_add_test(tc, test_dictionary_nested); + tcase_add_test(tc, test_dictionary_iterator_empty); + tcase_add_test(tc, test_dictionary_iterator_one_element); + tcase_add_test(tc, test_dictionary_iterator_many_elements_sorted); + suite_add_tcase(s, tc); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/test-file-variable.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,179 @@
+#endif /* HAVE_CONFIG_H */ +#include <gplate/gplate.h> +#include <glib/gstdio.h> +#include "test-collection.h" +#include "test-object.h" +/****************************************************************************** + *****************************************************************************/ +static GPlateVariable *file = NULL; +/****************************************************************************** + *****************************************************************************/ +create_temp_file(void) { + gchar *filename = NULL; + fd = g_file_open_tmp("gplate-test-XXXXXX", &filename, NULL); + /* close the fd, basically we just did a touch ;) */ +test_file(GPlateFileVariable *file, const gchar *filename) { + GPlateCollection *c = GPLATE_COLLECTION(file); + test_collection_lookup(c, "filename", filename); + /* do a g_stat on the file */ + r = g_lstat(filename, &st); + fail_unless(r == 0, "Failed to stat '%s'", filename); + /* now run through and compare all of the values */ + test_collection_lookup_int(c, "dev", st.st_dev); + test_collection_lookup_int(c, "inode", st.st_ino); + test_collection_lookup_int(c, "mode", st.st_mode); + test_collection_lookup_int(c, "nlink", st.st_nlink); + test_collection_lookup_int(c, "uid", st.st_uid); + test_collection_lookup_int(c, "gid", st.st_gid); + test_collection_lookup_int(c, "rdev", st.st_rdev); + test_collection_lookup_int(c, "size", st.st_size); + test_collection_lookup_int(c, "blocksize", st.st_blksize); + test_collection_lookup_int(c, "blocks", st.st_blocks); + test_collection_lookup_int(c, "atime", st.st_atime); + test_collection_lookup_int(c, "mtime", st.st_mtime); + test_collection_lookup_int(c, "ctime", st.st_ctime); +/****************************************************************************** + *****************************************************************************/ +object_hierarchy_setup(void) { + gchar *filename = create_temp_file(); + file = gplate_file_variable_new("file", filename); + if(G_IS_OBJECT(file)) { + GPlateCollection *c = GPLATE_COLLECTION(file); + const gchar *filename = NULL; + filename = gplate_collection_lookup(c, "filename"); + g_object_unref(G_OBJECT(file)); +/****************************************************************************** + * Object Hierarchy Tests + *****************************************************************************/ +START_TEST(test_file_hierarchy_type) + test_object_is_a(G_OBJECT(file), GPLATE_TYPE_FILE_VARIABLE); +START_TEST(test_file_hierarchy_parent) + test_object_is_a(G_OBJECT(file), GPLATE_TYPE_DICTIONARY_VARIABLE); +START_TEST(test_file_hierarchy_grandparent) + test_object_is_a(G_OBJECT(file), GPLATE_TYPE_VARIABLE); +START_TEST(test_file_hierarchy_collection) + test_object_is_a(G_OBJECT(file), GPLATE_TYPE_COLLECTION); +/****************************************************************************** + *****************************************************************************/ +START_TEST(test_file_normal) + gchar *filename = create_temp_file(); + file = gplate_file_variable_new("file", filename); + fail_unless(GPLATE_IS_FILE_VARIABLE(file), + "Failed to create a GPlateFileVariable instance for '%s'", + test_file(GPLATE_FILE_VARIABLE(file), filename); +START_TEST(test_file_does_not_exist) + const gchar *filename = "non-existant file"; + file = gplate_file_variable_new("file", filename); + fail_unless(file != NULL, + "We should not have been able to create a GPlateFileVariable " +/****************************************************************************** + *****************************************************************************/ +file_variable_suite(void) { + Suite *s = suite_create("File Variable Suite"); + tc = tcase_create("Object hierarchy"); + tcase_add_checked_fixture(tc, object_hierarchy_setup, common_teardown); + tcase_add_test(tc, test_file_hierarchy_type); + tcase_add_test(tc, test_file_hierarchy_parent); + tcase_add_test(tc, test_file_hierarchy_grandparent); + tcase_add_test(tc, test_file_hierarchy_collection); + suite_add_tcase(s, tc); + tc = tcase_create("File Tests"); + tcase_add_checked_fixture(tc, NULL, common_teardown); + tcase_add_test(tc, test_file_normal); + tcase_add_test(tc, test_file_does_not_exist); + suite_add_tcase(s, tc); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/test-gplate-collection-interface.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,35 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +/****************************************************************************** + *****************************************************************************/ +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + gplate_config_load_default(); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/test-gplate-utility-functions.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,60 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +gplate_util_test_quoted_string_helper(const gchar *string, + const gchar *contents, gboolean value) + r = gplate_util_is_quoted_string(string, &c); + g_assert_cmpint(r, ==, value); + g_assert_cmpstr(c, ==, contents); +gplate_util_test_quoted_string(void) { + gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE); + gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE); + gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE); + gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE); + gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE); + gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE); + gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE); + gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE); + gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE); + gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE); + gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE); + gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE); +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/test-gplate.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,39 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include "tags/test-gplate-tag.h" +main(gint argc, gchar **argv) { + g_test_init(&argc, &argv, NULL); + gplate_config_load_default(); + test_gplate_functions_add_tests(); + test_gplate_tag_add_tests(); + test_gplate_variables_add_tests(); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/variables/CMakeLists.txt Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,13 @@
+set(TEST_GPLATE_VARIABLES_HEADERS + test-gplate-variables.h +set(TEST_GPLATE_VARIABLES_SOURCES + test-gplate-variables.c +add_library(test-gplate-variables STATIC + ${TEST_GPLATE_VARIABLES_HEADERS} + ${TEST_GPLATE_VARIABLES_SOURCES} --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/variables/test-gplate-variables.c Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,112 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#include <gplate/gplate.h> +/****************************************************************************** + *****************************************************************************/ +#define gplate_variable_test_value(v, expected) \ + g_assert_cmpstr(gplate_variable_get_value((v)), ==, (expected)); \ + g_object_unref(G_OBJECT((v))); \ +#define gplate_variable_test_from_string_helper(input, output) \ + GPlateVariable *v = gplate_variable_new_from_string("test", (input)); \ + gplate_variable_test_value(v, (output)); \ +gplate_variable_test_from_string(void) { + gplate_variable_test_from_string_helper(NULL, NULL); + gplate_variable_test_from_string_helper("", ""); + gplate_variable_test_from_string_helper( + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); + gplate_variable_test_from_string_helper("☀☁☂☃☄", "☀☁☂☃☄"); +#define gplate_variable_test_from_boolean_helper(input, output) \ + GPlateVariable *v = gplate_variable_new_from_boolean("test", (input)); \ + gplate_variable_test_value(v, (output)); \ +gplate_variable_test_from_boolean(void) { + gplate_variable_test_from_boolean_helper(TRUE, "TRUE"); + gplate_variable_test_from_boolean_helper(FALSE, "FALSE"); +#define gplate_variable_test_from_integer_helper(input, output) \ + GPlateVariable *v = gplate_variable_new_from_integer("test", (input)); \ + gplate_variable_test_value(v, (output)); \ +gplate_variable_test_from_integer(void) { + gplate_variable_test_from_integer_helper(-1, "-1"); + gplate_variable_test_from_integer_helper(0, "0"); + gplate_variable_test_from_integer_helper(1, "1"); +#define gplate_variable_test_from_float_helper(input, output) \ + GPlateVariable *v = gplate_variable_new_from_float("test", (input)); \ + gplate_variable_test_value(v, (output)); \ +gplate_variable_test_from_float(void) { + gplate_variable_test_from_float_helper(-1.0f, "-1.000000"); + gplate_variable_test_from_float_helper(-0.5f, "-0.500000"); + gplate_variable_test_from_float_helper(0.0f, "0.000000"); + gplate_variable_test_from_float_helper(0.5f, "0.500000"); + gplate_variable_test_from_float_helper(1.0f, "1.000000"); +#define gplate_variable_test_from_double_helper(input, output) \ + GPlateVariable *v = gplate_variable_new_from_double("test", (input)); \ + gplate_variable_test_value(v, (output)); \ +gplate_variable_test_from_double(void) { + gplate_variable_test_from_double_helper(-1.0, "-1"); + gplate_variable_test_from_double_helper(-0.5, "-0.5"); + gplate_variable_test_from_double_helper(0.0, "0"); + gplate_variable_test_from_double_helper(0.5, "0.5"); + gplate_variable_test_from_double_helper(1.0, "1"); +/****************************************************************************** + *****************************************************************************/ +test_gplate_variables_add_tests(void) { + g_test_add_func("/variable/from_string", gplate_variable_test_from_string); + g_test_add_func("/variable/from_boolean", gplate_variable_test_from_boolean); + g_test_add_func("/variable/from_integer", gplate_variable_test_from_integer); + g_test_add_func("/variable/from_float", gplate_variable_test_from_float); + g_test_add_func("/variable/from_double", gplate_variable_test_from_double); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplate/tests/variables/test-gplate-variables.h Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,30 @@
+ * GPlate - GObject based templating library + * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com> + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * This library 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 Lesser General Public License for more details. + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see <http://www.gnu.org/licenses/>. +#ifndef TEST_GPLATE_VARIABLES_H +#define TEST_GPLATE_VARIABLES_H +void test_gplate_variables_add_tests(void); +#endif /* TEST_GPLATE_VARIABLES_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/meson.build Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,79 @@
+ license : 'LGPL-2.0-or-later', + meson_version : '>=0.63.0', + default_options : ['c_std=c17', 'warning_level=2']) +############################################################################### +############################################################################### +parts = meson.project_version().split('-') + gplate_extra_version = parts[1] + gplate_extra_version = '' +parts = parts[0].split('.') +gplate_major_version = parts[0] +gplate_minor_version = parts[1] +gplate_micro_version = parts[2] +GPLATE_VERSION = '@0@.@1@.@2@'.format(gplate_soversion, +version_conf = configuration_data() +version_conf.set('GPLATE_MAJOR_VERSION', gplate_major_version) +version_conf.set('GPLATE_MINOR_VERSION', gplate_minor_version) +version_conf.set('GPLATE_MICRO_VERSION', gplate_micro_version) +version_conf.set('GPLATE_EXTRA_VERSION', gplate_extra_version) +version_conf.set('GPLATE_VERSION', meson.project_version()) +version_conf.set('GPLATE_API_VERSION', gplate_soversion) +############################################################################### +############################################################################### +pkgconfig = import('pkgconfig') +############################################################################### +############################################################################### +toplevel_inc = include_directories('.') +############################################################################### +############################################################################### +GLIB = dependency('glib-2.0', version : '>=2.70.0') + '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_70', + '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_70', +GOBJECT = dependency('gobject-2.0') +############################################################################### +############################################################################### +if get_option('doc') and not get_option('introspection') + error('Documentation requires GObject Introspection.') +gidocgen_dep = dependency( + 'gi-docgen', version: '>= 2021.1', + fallback: ['gi-docgen', 'dummy_dep'], + required: get_option('doc') +gidocgen = find_program('gi-docgen', required : get_option('doc')) +docs_dir = get_option('prefix') / get_option('datadir') / 'doc' +############################################################################### +############################################################################### --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/meson_options.txt Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,5 @@
+option('doc', type : 'boolean', value : false, + description : 'build documentation') +option('introspection', type : 'boolean', value : true, + description : 'build introspection data') --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/subprojects/gi-docgen.wrap Sat Mar 04 11:27:30 2023 -0600
@@ -0,0 +1,5 @@
+directory = gi-docgen-2023.1 +source_url = https://download.gnome.org/sources/gi-docgen/2023/gi-docgen-2023.1.tar.xz +source_filename = gi-docgen-2023.1.tar.xz +source_hash = a9a687c1b7c4a4139a214bd451e01ca86131a3161f68aa3e07325b06002bbfb6 --- a/tests/CMakeLists.txt Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
- -DTEST_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
-add_subdirectory(functions)
-add_subdirectory(variables)
-add_executable(test-gplate test-gplate.c)
-target_link_libraries(test-gplate
-###############################################################################
-###############################################################################
-set(GTESTER_TESTS "${TESTS}")
-set(GTESTER_LOG "testgplate.log")
-add_custom_target(tests ALL
- COMMAND ${GTESTER} -k --verbose -o ${GTESTER_LOG} test-gplate
--- a/tests/functions/CMakeLists.txt Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-set(TEST_GPLATE_FUNCTIONS_HEADERS
- test-gplate-functions.h
-set(TEST_GPLATE_FUNCTIONS_SOURCES
- test-gplate-functions.c
- test-gplate-for-function.c
- test-gplate-include-function.c
-add_library(test-gplate-functions STATIC
- ${TEST_GPLATE_FUNCTIONS_HEADERS}
- ${TEST_GPLATE_FUNCTIONS_SOURCES}
--- a/tests/functions/test-gplate-for-function.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-#include <gplate/variables/gplate-dictionary-variable.h>
-/******************************************************************************
- *****************************************************************************/
-} TestGPlateForFunctionData;
- GPlateTemplate *template;
- const gchar *template_string;
- TestGPlateForFunctionData *data;
-} TestGPlateForFunctionFixture;
-/******************************************************************************
- *****************************************************************************/
-test_gplate_for_function_setup(TestGPlateForFunctionFixture *fixture,
- fixture->template = gplate_template_new();
- fixture->dict = gplate_dictionary_variable_new("list");
- gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template),
-test_gplate_for_function_teardown(TestGPlateForFunctionFixture *fixture,
- g_object_unref(fixture->template);
- fixture->template = NULL;
- g_object_unref(fixture->dict);
- g_free(fixture->actual);
- fixture->actual = NULL;
- fixture->expected = NULL;
- g_error_free(fixture->error);
-/******************************************************************************
- *****************************************************************************/
-test_gplate_for_function(TestGPlateForFunctionFixture *fixture) {
- /* add the variables */
- for(i = 0; fixture->data[i].name; i++) {
- gplate_collection_add_string(fixture->dict,
- fixture->data[i].value);
- fixture->actual = gplate_template_render(fixture->template,
- fixture->template_string,
- g_assert(fixture->error == NULL);
- g_assert_cmpstr(fixture->expected, ==, fixture->actual);
-/******************************************************************************
- *****************************************************************************/
-test_gplate_for_function_zero_elements(TestGPlateForFunctionFixture *fixture,
- gconstpointer user_data)
- TestGPlateForFunctionData data[] = {
- fixture->template_string = "{% for in in line %}{{ i }}{% endfor %}";
- fixture->expected = "";
- test_gplate_for_function(fixture);
-test_gplate_for_function_one_element(TestGPlateForFunctionFixture *fixture,
- gconstpointer user_data)
- TestGPlateForFunctionData data[] = {
- fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}";
- fixture->expected = "1";
- test_gplate_for_function(fixture);
-test_gplate_for_function_two_elements(TestGPlateForFunctionFixture *fixture,
- gconstpointer user_data)
- TestGPlateForFunctionData data[] = {
- fixture->template_string = "{% for i in list %}{{ i }}{% endfor %}";
- fixture->expected = "AB";
- test_gplate_for_function(fixture);
-/******************************************************************************
- *****************************************************************************/
-test_gplate_for_function_add_tests(void) {
- g_test_add("/functions/foo/zero_elements",
- TestGPlateForFunctionFixture,
- test_gplate_for_function_setup,
- test_gplate_for_function_zero_elements,
- test_gplate_for_function_teardown);
- g_test_add("/functions/foo/one_element",
- TestGPlateForFunctionFixture,
- test_gplate_for_function_setup,
- test_gplate_for_function_one_element,
- test_gplate_for_function_teardown);
- g_test_add("/functions/foo/two_elements",
- TestGPlateForFunctionFixture,
- test_gplate_for_function_setup,
- test_gplate_for_function_two_elements,
- test_gplate_for_function_teardown);
--- a/tests/functions/test-gplate-functions.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include "test-gplate-functions.h"
-/******************************************************************************
- *****************************************************************************/
-test_gplate_functions_add_tests(void) {
- test_gplate_for_function_add_tests();
- test_gplate_include_function_add_tests();
--- a/tests/functions/test-gplate-functions.h Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#ifndef TEST_GPLATE_FUNCTIONS_H
-#define TEST_GPLATE_FUNCTIONS_H
-#include <gplate/gplate.h>
-void test_gplate_functions_add_tests(void);
-/* external prototypes */
-void test_gplate_for_function_add_tests(void);
-void test_gplate_include_function_add_tests(void);
-#endif /* TEST_GPLATE_FUNCTIONS_H */
--- a/tests/functions/test-gplate-include-function.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-/******************************************************************************
- *****************************************************************************/
- GPlateTemplate *template;
- const gchar *template_string;
-} TestGPlateIncludeFunctionFixture;
-/******************************************************************************
- *****************************************************************************/
-test_gplate_include_function_setup(TestGPlateIncludeFunctionFixture *fixture,
- fixture->template = gplate_template_new();
-test_gplate_include_function_teardown(TestGPlateIncludeFunctionFixture *fixture,
- g_object_unref(fixture->template);
- fixture->template = NULL;
- g_free(fixture->actual);
- fixture->actual = NULL;
- fixture->expected = NULL;
- g_error_free(fixture->error);
-/******************************************************************************
- *****************************************************************************/
-test_gplate_include_function_simple(TestGPlateIncludeFunctionFixture *fixture,
- fixture->expected = "including\nincluded!\n\ndone\n\n";
- path = g_build_filename(TEST_DIR, "templates", "simple.gplate", NULL);
- fixture->actual = gplate_template_render_file(fixture->template,
- g_assert(fixture->error == NULL);
- g_assert_cmpstr(fixture->expected, ==, fixture->actual);
-test_gplate_include_function_double(TestGPlateIncludeFunctionFixture *fixture,
- path = g_build_filename(TEST_DIR, "templates", "html.gplate", NULL);
- fixture->actual = gplate_template_render_file(fixture->template,
- g_assert(fixture->error == NULL);
- g_assert_cmpstr(fixture->expected, ==, fixture->actual);
-/******************************************************************************
- *****************************************************************************/
-test_gplate_include_function_add_tests(void) {
- g_test_add("/functions/include/simple",
- TestGPlateIncludeFunctionFixture,
- test_gplate_include_function_setup,
- test_gplate_include_function_simple,
- test_gplate_include_function_teardown);
- g_test_add("/functions/include/double",
- TestGPlateIncludeFunctionFixture,
- test_gplate_include_function_setup,
- test_gplate_include_function_double,
- test_gplate_include_function_teardown);
--- a/tests/tags/CMakeLists.txt Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-set(TEST_GPLATE_TAGS_HEADERS
-set(TEST_GPLATE_TAGS_SOURCES
- test-gplate-comment-tag.c
- test-gplate-variable-tag.c
-add_library(test-gplate-tags STATIC
- ${TEST_GPLATE_TAGS_HEADERS}
- ${TEST_GPLATE_TAGS_SOURCES}
--- a/tests/tags/test-gplate-comment-tag.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-#include "test-gplate-tag.h"
-/******************************************************************************
- *****************************************************************************/
-test_gplate_comment_tag_empty(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data, "{##}", "");
-test_gplate_comment_tag_whitespace(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data, "{# #}", "");
- test_gplate_tag_output(fixture, data, "{#\t#}", "");
- test_gplate_tag_output(fixture, data, "{#\n#}", "");
- test_gplate_tag_output(fixture, data, "{#\r#}", "");
- test_gplate_tag_output(fixture, data, "{#\r\n#}", "");
- test_gplate_tag_output(fixture, data, "{#\n\r#}", "");
-test_gplate_comment_tag_simple(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data, "{# foo#}", "");
- test_gplate_tag_output(fixture, data, "{#foo #}", "");
- test_gplate_tag_output(fixture, data, "{#\tfoo#}", "");
- test_gplate_tag_output(fixture, data, "{#foo\t#}", "");
- test_gplate_tag_output(fixture, data, "{#\nfoo#}", "");
- test_gplate_tag_output(fixture, data, "{#foo\n#}", "");
- test_gplate_tag_output(fixture, data, "{#\rfoo#}", "");
- test_gplate_tag_output(fixture, data, "{#foo\r#}", "");
- test_gplate_tag_output(fixture, data, "{#\r\nfoo#}", "");
- test_gplate_tag_output(fixture, data, "{#foo\r\n#}", "");
-/******************************************************************************
- *****************************************************************************/
-test_gplate_comment_tag_add_tests(void) {
- test_gplate_tag_add("/tags/comment/empty",
- test_gplate_comment_tag_empty);
- test_gplate_tag_add("/tags/comment/whitespace",
- test_gplate_comment_tag_whitespace);
- test_gplate_tag_add("/tags/comment/simple",
- test_gplate_comment_tag_simple);
--- a/tests/tags/test-gplate-tag.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include "test-gplate-tag.h"
-/******************************************************************************
- *****************************************************************************/
-test_gplate_tag_setup(TestGPlateTagFixture *fixture, gconstpointer data) {
- gplate_config_load_default();
- fixture->template = gplate_template_new();
-test_gplate_tag_teardown(TestGPlateTagFixture *fixture, gconstpointer data) {
- g_object_unref(fixture->template);
- fixture->template = NULL;
- g_error_free(fixture->error);
- g_free(fixture->actual);
- fixture->actual = NULL;
-/******************************************************************************
- *****************************************************************************/
-test_gplate_tag_output(TestGPlateTagFixture *fixture,
- const gchar *template_string,
- fixture->template_string = template_string;
- fixture->expected = expected;
- fixture->actual = gplate_template_render(fixture->template,
- fixture->template_string,
- g_assert(fixture->error == NULL);
- g_assert_cmpstr(fixture->expected, ==, fixture->actual);
-/******************************************************************************
- *****************************************************************************/
-test_gplate_tag_add_tests(void) {
- test_gplate_text_tag_add_tests();
- test_gplate_variable_tag_add_tests();
--- a/tests/tags/test-gplate-tag.h Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#ifndef TEST_GPLATE_TAG_H
-#define TEST_GPLATE_TAG_H
-#include <gplate/gplate.h>
-#define test_gplate_tag_add(path, func) \
- g_test_add((path), TestGPlateTagFixture, NULL, test_gplate_tag_setup, (func), test_gplate_tag_teardown)
-typedef struct _TestGPlateTagFixture TestGPlateTagFixture;
-typedef void (*TestGPlateTagFixtureFunc)(TestGPlateTagFixture *fixture, gconstpointer data);
-struct _TestGPlateTagFixture {
- GPlateTemplate *template;
- const gchar *template_string;
-void test_gplate_tag_setup(TestGPlateTagFixture *fixture, gconstpointer data);
-void test_gplate_tag_teardown(TestGPlateTagFixture *fixture, gconstpointer data);
-void test_gplate_tag_output(TestGPlateTagFixture *fixture, gconstpointer data, const gchar *template_string, const gchar *expected);
-void test_gplate_tag_add_tests(void);
-/* external prototypes */
-void test_gplate_comment_tag_add_tests(void);
-void test_gplate_text_tag_add_tests(void);
-void test_gplate_variable_tag_add_tests(void);
-#endif /* TEST_GPLATE_TAG_H */
--- a/tests/tags/test-gplate-text-tag.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-#include "test-gplate-tag.h"
-/******************************************************************************
- *****************************************************************************/
-test_gplate_text_tag_syntax_plain(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data,
- "simple template", "simple template");
-test_gplate_text_tag_syntax_keywords(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data,
- "extends if else endif for endfor",
- "extends if else endif for endfor");
-test_gplate_text_tag_syntax_keywords_case_sensitive(TestGPlateTagFixture *fixture,
- test_gplate_tag_output(fixture, data,
- "EXteNds iF eLse enDif fOr enDFor",
- "EXteNds iF eLse enDif fOr enDFor");
-test_gplate_text_tag_add_tests(void) {
- test_gplate_tag_add("/tags/text/plain",
- test_gplate_text_tag_syntax_plain);
- test_gplate_tag_add("/tags/text/keywords",
- test_gplate_text_tag_syntax_keywords);
- test_gplate_tag_add("/tags/text/keywords_case_sensitive",
- test_gplate_text_tag_syntax_keywords_case_sensitive);
--- a/tests/tags/test-gplate-variable-tag.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,232 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-#include "test-gplate-tag.h"
-/******************************************************************************
- *****************************************************************************/
-test_gplate_variable_tag(TestGPlateTagFixture *fixture, gconstpointer data,
- const gchar *template_string, const gchar *expected,
- const gchar *name = NULL, *value = NULL;
- va_start(vargs, expected);
- while((name = va_arg(vargs, const gchar *))) {
- value = va_arg(vargs, const gchar *);
- gplate_collection_add_string(GPLATE_COLLECTION(fixture->template),
- test_gplate_tag_output(fixture, data, template_string, expected);
-/******************************************************************************
- *****************************************************************************/
-test_gplate_variable_tag_single(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
-test_gplate_variable_tag_double(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "{{ foo }}{{ bar }}", "foobar",
-test_gplate_variable_tag_tripple(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "{{ foo }}{{ bar }}{{ baz }}", "foobarbaz",
-test_gplate_variable_tag_newline_prefix(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
-test_gplate_variable_tag_newline_suffix(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
-test_gplate_variable_tag_newline_wrapped(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
-test_gplate_variable_tag_single_quotes(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "foo '{{ bar }}' baz", "foo 'bar' baz",
-test_gplate_variable_tag_double_quotes(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "foo \"{{ bar }}\" baz", "foo \"bar\" baz",
-test_gplate_variable_tag_mixed_quotes(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "foo \"{{ bar }}' baz", "foo \"bar' baz",
- test_gplate_variable_tag(fixture, data,
- "foo '{{ bar }}\" baz", "foo 'bar\" baz",
-test_gplate_variable_tag_two_vars_one_block(TestGPlateTagFixture *fixture,
- test_gplate_variable_tag(fixture, data,
- "one {{ two five }} three",
-test_gplate_variable_tag_nested_single(TestGPlateTagFixture *fixture,
- GPlateVariable *dict = gplate_dictionary_variable_new("foo");
- gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template),
- gplate_collection_add_string(GPLATE_COLLECTION(dict),
- test_gplate_tag_output(fixture, data, "{{ foo.bar }}", "baz");
-test_gplate_variable_tag_nested_double(TestGPlateTagFixture *fixture,
- GPlateVariable *dict1 = gplate_dictionary_variable_new("foo");
- GPlateVariable *dict2 = gplate_dictionary_variable_new("bar");
- gplate_collection_add_variable(GPLATE_COLLECTION(fixture->template),
- gplate_collection_add_variable(GPLATE_COLLECTION(dict1), dict2);
- gplate_collection_add_string(GPLATE_COLLECTION(dict2),
- test_gplate_tag_output(fixture, data, "{{ foo.bar.baz }}", "42");
-/******************************************************************************
- *****************************************************************************/
-test_gplate_variable_tag_add_tests(void) {
- test_gplate_tag_add("/tags/variable/single",
- test_gplate_variable_tag_single);
- test_gplate_tag_add("/tags/variable/double",
- test_gplate_variable_tag_double);
- test_gplate_tag_add("/tags/variable/tripple",
- test_gplate_variable_tag_tripple);
- test_gplate_tag_add("/tags/variable/newline_prefix",
- test_gplate_variable_tag_newline_prefix);
- test_gplate_tag_add("/tags/variable/newline_suffix",
- test_gplate_variable_tag_newline_suffix);
- test_gplate_tag_add("/tags/variable/newline_wrapped",
- test_gplate_variable_tag_newline_wrapped);
- test_gplate_tag_add("/tags/variable/quotes/single",
- test_gplate_variable_tag_single_quotes);
- test_gplate_tag_add("/tags/variable/quotes/double",
- test_gplate_variable_tag_double_quotes);
- test_gplate_tag_add("/tags/variable/quotes/mixed",
- test_gplate_variable_tag_mixed_quotes);
- test_gplate_tag_add("/tags/variable/two_vars_one_block",
- test_gplate_variable_tag_two_vars_one_block);
- test_gplate_tag_add("/tags/variable/nested/single",
- test_gplate_variable_tag_nested_single);
- test_gplate_tag_add("/tags/variable/nested/double",
- test_gplate_variable_tag_nested_double);
--- a/tests/templates/footer.gplate Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,2 +0,0 @@
--- a/tests/templates/header.gplate Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
--- a/tests/templates/html.gplate Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-{% include "header.gplate" %}in the body{% include "footer.gplate" %}
--- a/tests/templates/simple-include.gplate Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
--- a/tests/templates/simple.gplate Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-{% include "simple-include.gplate" %}
--- a/tests/test-collection.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-#include "test-collection.h"
-test_collection_lookup(GPlateCollection *collection, const gchar *name,
- v = gplate_collection_lookup(collection, name);
- test_string(expected, v);
-test_collection_lookup_int(GPlateCollection *collection, const gchar *name,
- v = gplate_collection_lookup(collection, name);
- e = g_strdup_printf("%d", expected);
--- a/tests/test-dictionary-variable.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,255 +0,0 @@
-#endif /* HAVE_CONFIG_H */
-#include <gplate/gplate.h>
-#include "test-collection.h"
-#include "test-object.h"
-/******************************************************************************
- *****************************************************************************/
-/******************************************************************************
- *****************************************************************************/
-static GPlateVariable *dict = NULL;
-static GPlateIterator *iter = NULL;
-/******************************************************************************
- *****************************************************************************/
-iterator_test(VariableData *vd) {
- /* add all the values and make sure they got entered correctly */
- for(i = 0, count = 0; vd[i].name; i++, count++) {
- gplate_collection_add_string(dict, vd[i].name, vd[i].value);
- test_collection_lookup(GPLATE_COLLECTION(dict),
- vd[i].name, vd[i].value);
- iter = gplate_collection_get_iterator(GPLATE_COLLECTION(dict));
- while(gplate_iterator_has_next(iter)) {
- GPlateVariable *var = gplate_iterator_next(iter);
- const gchar *value = gplate_variable_get_value(var);
- test_string(vd[i++].value, value);
- fail_unless(i == count, "Iterated over %d/%d elements.", i, count);
-/******************************************************************************
- *****************************************************************************/
-collection_interface_setup(void) {
- dict = gplate_dictionary_variable_new("dict");
-collection_interface_teardown(void) {
- g_object_unref(G_OBJECT(dict));
- g_object_unref(G_OBJECT(iter));
-/******************************************************************************
- * Object Hierarchy Tests
- *****************************************************************************/
-START_TEST(test_dictionary_hierarchy_type)
- test_object_is_a(G_OBJECT(dict), GPLATE_TYPE_DICTIONARY_VARIABLE);
-START_TEST(test_dictionary_hierarchy_parent)
- test_object_is_a(G_OBJECT(dict), GPLATE_TYPE_VARIABLE);
-START_TEST(test_dictionary_hierarchy_collection)
- test_object_is_a(G_OBJECT(dict), GPLATE_TYPE_COLLECTION);
-/******************************************************************************
- * Collection Interface Tests
- *****************************************************************************/
-START_TEST(test_dictionary_add_string_null)
- gplate_collection_add_string(dict, "null", NULL);
- test_collection_lookup(GPLATE_COLLECTION(dict), "null", NULL);
-START_TEST(test_dictionary_add_string_empty)
- gplate_collection_add_string(dict, "empty", "");
- test_collection_lookup(GPLATE_COLLECTION(dict), "empty", "");
-START_TEST(test_dictionary_add_string)
- gplate_collection_add_string(dict, "string", "string");
- test_collection_lookup(GPLATE_COLLECTION(dict), "string", "string");
-START_TEST(test_dictionary_add_boolean_true)
- gplate_collection_add_boolean(dict, "true", TRUE);
- test_collection_lookup(GPLATE_COLLECTION(dict), "true", "TRUE");
-START_TEST(test_dictionary_add_boolean_false)
- gplate_collection_add_boolean(dict, "false", FALSE);
- test_collection_lookup(GPLATE_COLLECTION(dict), "false", "FALSE");
-START_TEST(test_dictionary_add_float_positive)
- gplate_collection_add_float(dict, "pi", 3.14f);
- test_collection_lookup(GPLATE_COLLECTION(dict), "pi", "3.140000");
-START_TEST(test_dictionary_add_float_positive_whole)
- gplate_collection_add_float(dict, "three", 3.0f);
- test_collection_lookup(GPLATE_COLLECTION(dict), "three", "3.000000");
-START_TEST(test_dictionary_add_float_negative)
- gplate_collection_add_float(dict, "negativepi", -3.14f);
- test_collection_lookup(GPLATE_COLLECTION(dict), "negativepi", "-3.140000");
-START_TEST(test_dictionary_add_float_negative_whole)
- gplate_collection_add_float(dict, "negativethree", -3.0f);
- test_collection_lookup(GPLATE_COLLECTION(dict), "negativethree", "-3.000000");
-START_TEST(test_dictionary_add_double_positive)
- gplate_collection_add_double(dict, "e", 2.71);
- test_collection_lookup(GPLATE_COLLECTION(dict), "e", "2.71");
-START_TEST(test_dictionary_add_double_positive_whole)
- gplate_collection_add_double(dict, "two", 2.0);
- test_collection_lookup(GPLATE_COLLECTION(dict), "two", "2");
-START_TEST(test_dictionary_add_double_negative)
- gplate_collection_add_double(dict, "negativee", -2.71);
- test_collection_lookup(GPLATE_COLLECTION(dict), "negativee", "-2.71");
-START_TEST(test_dictionary_add_double_negative_whole)
- gplate_collection_add_double(dict, "negativetwo", -2.0);
- test_collection_lookup(GPLATE_COLLECTION(dict), "negativetwo", "-2");
-START_TEST(test_dictionary_nested)
- GPlateVariable *nested = gplate_dictionary_variable_new("nested");
- gplate_collection_add_variable(GPLATE_COLLECTION(dict), nested);
- gplate_collection_add_string(GPLATE_COLLECTION(nested), "nestedstring",
- test_collection_lookup(GPLATE_COLLECTION(dict), "nested.nestedstring",
-START_TEST(test_dictionary_iterator_empty)
-START_TEST(test_dictionary_iterator_one_element)
-START_TEST(test_dictionary_iterator_many_elements_sorted)
-/******************************************************************************
- *****************************************************************************/
-dictionary_variable_suite(void) {
- Suite *s = suite_create("Dictionary Variable Suite");
- tc = tcase_create("Object hierarchy");
- tcase_add_checked_fixture(tc, collection_interface_setup,
- collection_interface_teardown);
- tcase_add_test(tc, test_dictionary_hierarchy_type);
- tcase_add_test(tc, test_dictionary_hierarchy_parent);
- tcase_add_test(tc, test_dictionary_hierarchy_collection);
- suite_add_tcase(s, tc);
- /* collection interface */
- tc = tcase_create("Collection Interface");
- tcase_add_checked_fixture(tc, collection_interface_setup,
- collection_interface_teardown);
- tcase_add_test(tc, test_dictionary_add_string_null);
- tcase_add_test(tc, test_dictionary_add_string_empty);
- tcase_add_test(tc, test_dictionary_add_string);
- tcase_add_test(tc, test_dictionary_add_boolean_true);
- tcase_add_test(tc, test_dictionary_add_boolean_false);
- tcase_add_test(tc, test_dictionary_add_float_positive);
- tcase_add_test(tc, test_dictionary_add_float_positive_whole);
- tcase_add_test(tc, test_dictionary_add_float_negative);
- tcase_add_test(tc, test_dictionary_add_float_negative_whole);
- tcase_add_test(tc, test_dictionary_add_double_positive);
- tcase_add_test(tc, test_dictionary_add_double_positive_whole);
- tcase_add_test(tc, test_dictionary_add_double_negative);
- tcase_add_test(tc, test_dictionary_add_double_negative_whole);
- tcase_add_test(tc, test_dictionary_nested);
- tcase_add_test(tc, test_dictionary_iterator_empty);
- tcase_add_test(tc, test_dictionary_iterator_one_element);
- tcase_add_test(tc, test_dictionary_iterator_many_elements_sorted);
- suite_add_tcase(s, tc);
--- a/tests/test-file-variable.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,179 +0,0 @@
-#endif /* HAVE_CONFIG_H */
-#include <gplate/gplate.h>
-#include <glib/gstdio.h>
-#include "test-collection.h"
-#include "test-object.h"
-/******************************************************************************
- *****************************************************************************/
-static GPlateVariable *file = NULL;
-/******************************************************************************
- *****************************************************************************/
-create_temp_file(void) {
- gchar *filename = NULL;
- fd = g_file_open_tmp("gplate-test-XXXXXX", &filename, NULL);
- /* close the fd, basically we just did a touch ;) */
-test_file(GPlateFileVariable *file, const gchar *filename) {
- GPlateCollection *c = GPLATE_COLLECTION(file);
- test_collection_lookup(c, "filename", filename);
- /* do a g_stat on the file */
- r = g_lstat(filename, &st);
- fail_unless(r == 0, "Failed to stat '%s'", filename);
- /* now run through and compare all of the values */
- test_collection_lookup_int(c, "dev", st.st_dev);
- test_collection_lookup_int(c, "inode", st.st_ino);
- test_collection_lookup_int(c, "mode", st.st_mode);
- test_collection_lookup_int(c, "nlink", st.st_nlink);
- test_collection_lookup_int(c, "uid", st.st_uid);
- test_collection_lookup_int(c, "gid", st.st_gid);
- test_collection_lookup_int(c, "rdev", st.st_rdev);
- test_collection_lookup_int(c, "size", st.st_size);
- test_collection_lookup_int(c, "blocksize", st.st_blksize);
- test_collection_lookup_int(c, "blocks", st.st_blocks);
- test_collection_lookup_int(c, "atime", st.st_atime);
- test_collection_lookup_int(c, "mtime", st.st_mtime);
- test_collection_lookup_int(c, "ctime", st.st_ctime);
-/******************************************************************************
- *****************************************************************************/
-object_hierarchy_setup(void) {
- gchar *filename = create_temp_file();
- file = gplate_file_variable_new("file", filename);
- if(G_IS_OBJECT(file)) {
- GPlateCollection *c = GPLATE_COLLECTION(file);
- const gchar *filename = NULL;
- filename = gplate_collection_lookup(c, "filename");
- g_object_unref(G_OBJECT(file));
-/******************************************************************************
- * Object Hierarchy Tests
- *****************************************************************************/
-START_TEST(test_file_hierarchy_type)
- test_object_is_a(G_OBJECT(file), GPLATE_TYPE_FILE_VARIABLE);
-START_TEST(test_file_hierarchy_parent)
- test_object_is_a(G_OBJECT(file), GPLATE_TYPE_DICTIONARY_VARIABLE);
-START_TEST(test_file_hierarchy_grandparent)
- test_object_is_a(G_OBJECT(file), GPLATE_TYPE_VARIABLE);
-START_TEST(test_file_hierarchy_collection)
- test_object_is_a(G_OBJECT(file), GPLATE_TYPE_COLLECTION);
-/******************************************************************************
- *****************************************************************************/
-START_TEST(test_file_normal)
- gchar *filename = create_temp_file();
- file = gplate_file_variable_new("file", filename);
- fail_unless(GPLATE_IS_FILE_VARIABLE(file),
- "Failed to create a GPlateFileVariable instance for '%s'",
- test_file(GPLATE_FILE_VARIABLE(file), filename);
-START_TEST(test_file_does_not_exist)
- const gchar *filename = "non-existant file";
- file = gplate_file_variable_new("file", filename);
- fail_unless(file != NULL,
- "We should not have been able to create a GPlateFileVariable "
-/******************************************************************************
- *****************************************************************************/
-file_variable_suite(void) {
- Suite *s = suite_create("File Variable Suite");
- tc = tcase_create("Object hierarchy");
- tcase_add_checked_fixture(tc, object_hierarchy_setup, common_teardown);
- tcase_add_test(tc, test_file_hierarchy_type);
- tcase_add_test(tc, test_file_hierarchy_parent);
- tcase_add_test(tc, test_file_hierarchy_grandparent);
- tcase_add_test(tc, test_file_hierarchy_collection);
- suite_add_tcase(s, tc);
- tc = tcase_create("File Tests");
- tcase_add_checked_fixture(tc, NULL, common_teardown);
- tcase_add_test(tc, test_file_normal);
- tcase_add_test(tc, test_file_does_not_exist);
- suite_add_tcase(s, tc);
--- a/tests/test-gplate-collection-interface.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-/******************************************************************************
- *****************************************************************************/
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- gplate_config_load_default();
--- a/tests/test-gplate-utility-functions.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-gplate_util_test_quoted_string_helper(const gchar *string,
- const gchar *contents, gboolean value)
- r = gplate_util_is_quoted_string(string, &c);
- g_assert_cmpint(r, ==, value);
- g_assert_cmpstr(c, ==, contents);
-gplate_util_test_quoted_string(void) {
- gplate_util_test_quoted_string_helper("\"abc\"", "abc", TRUE);
- gplate_util_test_quoted_string_helper("\"abc def\"", "abc def", TRUE);
- gplate_util_test_quoted_string_helper("\"abc\tdef\bghi\"", "abc\tdef\bghi", TRUE);
- gplate_util_test_quoted_string_helper("abc \"def\"", NULL, FALSE);
- gplate_util_test_quoted_string_helper("\"abc\" def", NULL, FALSE);
- gplate_util_test_quoted_string_helper("'abc'", "abc", TRUE);
- gplate_util_test_quoted_string_helper("'abc def'", "abc def", TRUE);
- gplate_util_test_quoted_string_helper("'abc\tdef\bghi'", "abc\tdef\bghi", TRUE);
- gplate_util_test_quoted_string_helper("abc 'def'", NULL, FALSE);
- gplate_util_test_quoted_string_helper("'abc' def", NULL, FALSE);
- gplate_util_test_quoted_string_helper("'abc\"", NULL, FALSE);
- gplate_util_test_quoted_string_helper("\"abc'", NULL, FALSE);
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- g_test_add_func("/util/quoted_string", gplate_util_test_quoted_string);
--- a/tests/test-gplate.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include "tags/test-gplate-tag.h"
-main(gint argc, gchar **argv) {
- g_test_init(&argc, &argv, NULL);
- gplate_config_load_default();
- test_gplate_functions_add_tests();
- test_gplate_tag_add_tests();
- test_gplate_variables_add_tests();
--- a/tests/variables/CMakeLists.txt Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-set(TEST_GPLATE_VARIABLES_HEADERS
- test-gplate-variables.h
-set(TEST_GPLATE_VARIABLES_SOURCES
- test-gplate-variables.c
-add_library(test-gplate-variables STATIC
- ${TEST_GPLATE_VARIABLES_HEADERS}
- ${TEST_GPLATE_VARIABLES_SOURCES}
--- a/tests/variables/test-gplate-variables.c Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#include <gplate/gplate.h>
-/******************************************************************************
- *****************************************************************************/
-#define gplate_variable_test_value(v, expected) \
- g_assert_cmpstr(gplate_variable_get_value((v)), ==, (expected)); \
- g_object_unref(G_OBJECT((v))); \
-#define gplate_variable_test_from_string_helper(input, output) \
- GPlateVariable *v = gplate_variable_new_from_string("test", (input)); \
- gplate_variable_test_value(v, (output)); \
-gplate_variable_test_from_string(void) {
- gplate_variable_test_from_string_helper(NULL, NULL);
- gplate_variable_test_from_string_helper("", "");
- gplate_variable_test_from_string_helper(
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
- gplate_variable_test_from_string_helper("☀☁☂☃☄", "☀☁☂☃☄");
-#define gplate_variable_test_from_boolean_helper(input, output) \
- GPlateVariable *v = gplate_variable_new_from_boolean("test", (input)); \
- gplate_variable_test_value(v, (output)); \
-gplate_variable_test_from_boolean(void) {
- gplate_variable_test_from_boolean_helper(TRUE, "TRUE");
- gplate_variable_test_from_boolean_helper(FALSE, "FALSE");
-#define gplate_variable_test_from_integer_helper(input, output) \
- GPlateVariable *v = gplate_variable_new_from_integer("test", (input)); \
- gplate_variable_test_value(v, (output)); \
-gplate_variable_test_from_integer(void) {
- gplate_variable_test_from_integer_helper(-1, "-1");
- gplate_variable_test_from_integer_helper(0, "0");
- gplate_variable_test_from_integer_helper(1, "1");
-#define gplate_variable_test_from_float_helper(input, output) \
- GPlateVariable *v = gplate_variable_new_from_float("test", (input)); \
- gplate_variable_test_value(v, (output)); \
-gplate_variable_test_from_float(void) {
- gplate_variable_test_from_float_helper(-1.0f, "-1.000000");
- gplate_variable_test_from_float_helper(-0.5f, "-0.500000");
- gplate_variable_test_from_float_helper(0.0f, "0.000000");
- gplate_variable_test_from_float_helper(0.5f, "0.500000");
- gplate_variable_test_from_float_helper(1.0f, "1.000000");
-#define gplate_variable_test_from_double_helper(input, output) \
- GPlateVariable *v = gplate_variable_new_from_double("test", (input)); \
- gplate_variable_test_value(v, (output)); \
-gplate_variable_test_from_double(void) {
- gplate_variable_test_from_double_helper(-1.0, "-1");
- gplate_variable_test_from_double_helper(-0.5, "-0.5");
- gplate_variable_test_from_double_helper(0.0, "0");
- gplate_variable_test_from_double_helper(0.5, "0.5");
- gplate_variable_test_from_double_helper(1.0, "1");
-/******************************************************************************
- *****************************************************************************/
-test_gplate_variables_add_tests(void) {
- g_test_add_func("/variable/from_string", gplate_variable_test_from_string);
- g_test_add_func("/variable/from_boolean", gplate_variable_test_from_boolean);
- g_test_add_func("/variable/from_integer", gplate_variable_test_from_integer);
- g_test_add_func("/variable/from_float", gplate_variable_test_from_float);
- g_test_add_func("/variable/from_double", gplate_variable_test_from_double);
--- a/tests/variables/test-gplate-variables.h Sat Mar 04 10:36:35 2023 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
- * GPlate - GObject based templating library
- * Copyright (C) 2007-2012 Gary Kramlich <grim@reaperworld.com>
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This library 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 Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library. If not, see <http://www.gnu.org/licenses/>.
-#ifndef TEST_GPLATE_VARIABLES_H
-#define TEST_GPLATE_VARIABLES_H
-void test_gplate_variables_add_tests(void);
-#endif /* TEST_GPLATE_VARIABLES_H */