Added gplugin_manager_find_plugin_with_newest_version so clients aren't left with the task of figuring out which plugin to load.
--- a/ChangeLog Sun Apr 12 01:27:32 2020 +0000
+++ b/ChangeLog Sun Apr 12 02:45:51 2020 -0500
@@ -18,6 +18,7 @@
* Renamed the GPluginManager::load-failed signal to
GPluginManager::load-plugin-failed and added the error, if any, that the
plugin returned. (Gary Kramlich)
+ * Added gplugin_manager_find_plugin_with_newest_version. * Removed the moonscript support from the Lua loader. (Gary Kramlich)
--- a/gplugin/gplugin-manager.c Sun Apr 12 01:27:32 2020 +0000
+++ b/gplugin/gplugin-manager.c Sun Apr 12 02:45:51 2020 -0500
@@ -1649,7 +1649,6 @@
for(l = plugins; l; l = l->next) {
GPluginPlugin *plugin = GPLUGIN_PLUGIN(l->data);
GPluginPluginInfo *info = NULL;
const gchar *found_version = NULL;
@@ -1657,23 +1656,15 @@
/* get the plugin's version from it's info */
info = gplugin_plugin_get_info(plugin);
found_version = gplugin_plugin_info_get_version(info);
- g_object_unref(G_OBJECT(info));
/* now compare the version of the plugin to passed in version. This
* should be done in this order so it's easier to track the operators.
* IE: we want to keep the inequality the same.
- result = gplugin_version_compare(found_version, version, &error);
- "failed to compare versions for %s: %s",
- error->message ? error->message : _("unknown error"));
+ result = gplugin_version_compare(found_version, version);
+ /* we need to keep info around until we're done using found_version */ + g_object_unref(G_OBJECT(info)); keep = (g_strcmp0(op, "<") == 0 || g_strcmp0(op, "<=") == 0);
@@ -1753,6 +1744,81 @@
+ * gplugin_manager_find_plugin_with_newest_version: + * @id: The id of the plugin to find. + * Calls gplugin_manager_find_plugins() with @id, and then returns the Plugins + * with the highest version number or %NULL if no plugins with @id are found. + * Returns: (transfer full): The #GPluginPlugin with an id of @id that has the + * highest version number, or %NULL if no plugins were found with @id. +gplugin_manager_find_plugin_with_newest_version(const gchar *id) + GPluginPlugin *plugin_a = NULL; + GPluginPluginInfo *info_a = NULL; + const gchar *version_a = NULL; + g_return_val_if_fail(id != NULL, NULL); + l = gplugin_manager_find_plugins(id); + for(; l != NULL; l = g_slist_delete_link(l, l)) { + GPluginPlugin *plugin_b = NULL; + GPluginPluginInfo *info_b = NULL; + const gchar *version_b = NULL; + if(!GPLUGIN_IS_PLUGIN(l->data)) { + plugin_b = GPLUGIN_PLUGIN(l->data); + info_b = gplugin_plugin_get_info(plugin_b); + /* if this is the first plugin we've found, set the a values and + if(!GPLUGIN_IS_PLUGIN(plugin_a)) { + version_a = gplugin_plugin_info_get_version(info_a); + /* at this point, we've seen another plugin, so we need to compare + version_b = gplugin_plugin_info_get_version(info_b); + cmp = gplugin_version_compare(version_a, version_b); + /* plugin_b has a newer version */ + /* unref the old objects */ + g_clear_object(&plugin_a); + g_clear_object(&info_a); + /* now point the pointers to the plugin_b pointers */ + /* plugin_b has an older or equal to version so we keep plugin_a */ + g_clear_object(&plugin_b); + g_clear_object(&info_b); + g_clear_object(&info_a); * gplugin_manager_get_plugin_dependencies:
* @plugin: The #GPluginPlugin whose dependencies to get.
* @error: (out) (nullable): Return address for a #GError.
--- a/gplugin/gplugin-manager.h Sun Apr 12 01:27:32 2020 +0000
+++ b/gplugin/gplugin-manager.h Sun Apr 12 02:45:51 2020 -0500
@@ -59,6 +59,7 @@
GSList *gplugin_manager_find_plugins_with_state(GPluginPluginState state);
GPluginPlugin *gplugin_manager_find_plugin(const gchar *id);
+GPluginPlugin *gplugin_manager_find_plugin_with_newest_version(const gchar *id); GSList *gplugin_manager_get_plugin_dependencies(
--- a/gplugin/gplugin-version.c Sun Apr 12 01:27:32 2020 +0000
+++ b/gplugin/gplugin-version.c Sun Apr 12 02:45:51 2020 -0500
@@ -66,29 +66,52 @@
+ * gplugin_version_parser: + * @version: The string version to parse. + * @major: (out) (nullable): A return gint pointer for the major version. + * @minor: (out) (nullable): A return gint pointer for the minor version. + * @micro: (out) (nullable): A return gint pointer for the micro version. + * @extra: (out) (nullable): A return gchar * pointer for any extra version + * Attempts to parse a version string into its @major, @minor, @micro, and + * @extra parts. If @version doesn't match a semantic version string, @major + * will be set to %-1, @minor will be set to %0, and @micro will be set to %0.
gboolean matches = FALSE;
- matches = g_regex_match(regex, v, 0, &info);
+ /* initialize everything to our failed state */ + /* if a version was not provided, return our failed values */ + matches = g_regex_match(regex, version, 0, &info);
- _("%s does not match the version regex"),
+ /* if we failed to match the regex, just return our failed values */ /* grab the major version */
@@ -113,12 +136,11 @@
/* grab the extra version */
*extra = g_match_info_fetch_named(info, "extra");
g_match_info_unref(info);
/******************************************************************************
@@ -216,7 +238,6 @@
* gplugin_version_compare:
* @v1: The first version to compare.
* @v2: The second version to compare.
- * @error: (out) (nullable): A #GError return address if there are any errors.
* A semantic version checker which ignores any characters after the micro
@@ -225,25 +246,21 @@
* greater than 0 if @v1 is greater than @v2.
-gplugin_version_compare(const gchar *v1, const gchar *v2, GError **error)
+gplugin_version_compare(const gchar *v1, const gchar *v2) gint v1_maj = 0, v1_min = 0, v1_mic = 0;
gint v2_maj = 0, v2_min = 0, v2_mic = 0;
- g_return_val_if_fail(v1 != NULL, 1);
- g_return_val_if_fail(v2 != NULL, 2);
gplugin_version_lazy_init();
- /* make sure v1 matches the regex */
- if(!gplugin_version_parser(v1, &v1_maj, &v1_min, &v1_mic, NULL, error))
+ gplugin_version_parser(v1, &v1_maj, &v1_min, &v1_mic, NULL); - /* make sure v2 matches the regex */
- if(!gplugin_version_parser(v2, &v2_maj, &v2_min, &v2_mic, NULL, error))
+ gplugin_version_parser(v2, &v2_maj, &v2_min, &v2_mic, NULL); /* now figure out if they match */
--- a/gplugin/gplugin-version.h.in Sun Apr 12 01:27:32 2020 +0000
+++ b/gplugin/gplugin-version.h.in Sun Apr 12 02:45:51 2020 -0500
@@ -40,7 +40,7 @@
const gchar *gplugin_version_check(guint major, guint minor, guint micro);
-gint gplugin_version_compare(const gchar *v1, const gchar *v2, GError **error);
+gint gplugin_version_compare(const gchar *v1, const gchar *v2); --- a/gplugin/tests/meson.build Sun Apr 12 01:27:32 2020 +0000
+++ b/gplugin/tests/meson.build Sun Apr 12 02:45:51 2020 -0500
@@ -1,15 +1,16 @@
###############################################################################
###############################################################################
+subdir('load-on-query-fail') subdir('load-on-query-pass')
-subdir('load-on-query-fail')
+subdir('newest-version') +subdir('unresolved-symbol') subdir('versioned-dependencies')
-subdir('unresolved-symbol')
###############################################################################
@@ -37,6 +38,11 @@
dependencies : [gplugin_dep, GLIB, GOBJECT])
test('Loader Registration', e)
+e = executable('test-newest-version', 'test-newest-version.c', + c_args : ['-DTEST_DIR="@0@/newest-version/"'.format(meson.current_build_dir())], + dependencies : [gplugin_dep, GLIB, GOBJECT]) +test('Find Plugins Newest Version', e) e = executable('test-option-group', 'test-option-group.c',
dependencies : [gplugin_dep, GLIB, GOBJECT])
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/newest-version/meson.build Sun Apr 12 02:45:51 2020 -0500
@@ -0,0 +1,35 @@
+shared_module('multiple-semantic-1.0.0', 'multiple-semantic-1.0.0.c', + dependencies : [gplugin_dep, GLIB]) +shared_module('multiple-semantic-1.1.0', 'multiple-semantic-1.1.0.c', + dependencies : [gplugin_dep, GLIB]) +shared_module('no-version-and-semantic-no-version', + 'no-version-and-semantic-no-version.c', + dependencies : [gplugin_dep, GLIB]) +shared_module('no-version-and-semantic-semantic', + 'no-version-and-semantic-semantic.c', + dependencies : [gplugin_dep, GLIB]) +shared_module('non-semantic-and-semantic-non-semantic', + 'non-semantic-and-semantic-non-semantic.c', + dependencies : [gplugin_dep, GLIB]) +shared_module('non-semantic-and-semantic-semantic', + 'non-semantic-and-semantic-semantic.c', + dependencies : [gplugin_dep, GLIB]) +shared_module('solo-no-version', 'solo-no-version.c', + dependencies : [gplugin_dep, GLIB]) +shared_module('solo-non-semantic', 'solo-non-semantic.c', + dependencies : [gplugin_dep, GLIB]) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/newest-version/multiple-semantic-1.0.0.c Sun Apr 12 02:45:51 2020 -0500
@@ -0,0 +1,47 @@
+ * Copyright (C) 2011-2020 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 2 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 <gplugin-native.h> +G_MODULE_EXPORT GPluginPluginInfo * +gplugin_query(G_GNUC_UNUSED GError **error) + return gplugin_plugin_info_new( + "gplugin/test-newest-version/multiple-semantic", +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/newest-version/multiple-semantic-1.1.0.c Sun Apr 12 02:45:51 2020 -0500
@@ -0,0 +1,47 @@
+ * Copyright (C) 2011-2020 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 2 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 <gplugin-native.h> +G_MODULE_EXPORT GPluginPluginInfo * +gplugin_query(G_GNUC_UNUSED GError **error) + return gplugin_plugin_info_new( + "gplugin/test-newest-version/multiple-semantic", +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/newest-version/no-version-and-semantic-no-version.c Sun Apr 12 02:45:51 2020 -0500
@@ -0,0 +1,46 @@
+ * Copyright (C) 2011-2020 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 2 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 <gplugin-native.h> +G_MODULE_EXPORT GPluginPluginInfo * +gplugin_query(G_GNUC_UNUSED GError **error) + return gplugin_plugin_info_new( + "gplugin/test-newest-version/no-version-and-semantic", +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/newest-version/no-version-and-semantic-semantic.c Sun Apr 12 02:45:51 2020 -0500
@@ -0,0 +1,47 @@
+ * Copyright (C) 2011-2020 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 2 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 <gplugin-native.h> +G_MODULE_EXPORT GPluginPluginInfo * +gplugin_query(G_GNUC_UNUSED GError **error) + return gplugin_plugin_info_new( + "gplugin/test-newest-version/no-version-and-semantic", +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/newest-version/non-semantic-and-semantic-non-semantic.c Sun Apr 12 02:45:51 2020 -0500
@@ -0,0 +1,47 @@
+ * Copyright (C) 2011-2020 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 2 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 <gplugin-native.h> +G_MODULE_EXPORT GPluginPluginInfo * +gplugin_query(G_GNUC_UNUSED GError **error) + return gplugin_plugin_info_new( + "gplugin/test-newest-version/non-semantic-and-semantic", +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/newest-version/non-semantic-and-semantic-semantic.c Sun Apr 12 02:45:51 2020 -0500
@@ -0,0 +1,47 @@
+ * Copyright (C) 2011-2020 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 2 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 <gplugin-native.h> +G_MODULE_EXPORT GPluginPluginInfo * +gplugin_query(G_GNUC_UNUSED GError **error) + return gplugin_plugin_info_new( + "gplugin/test-newest-version/non-semantic-and-semantic", +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/newest-version/solo-no-version.c Sun Apr 12 02:45:51 2020 -0500
@@ -0,0 +1,46 @@
+ * Copyright (C) 2011-2020 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 2 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 <gplugin-native.h> +G_MODULE_EXPORT GPluginPluginInfo * +gplugin_query(G_GNUC_UNUSED GError **error) + return gplugin_plugin_info_new( + "gplugin/test-newest-version/solo-no-version", +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/newest-version/solo-non-semantic.c Sun Apr 12 02:45:51 2020 -0500
@@ -0,0 +1,47 @@
+ * Copyright (C) 2011-2020 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 2 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 <gplugin-native.h> +G_MODULE_EXPORT GPluginPluginInfo * +gplugin_query(G_GNUC_UNUSED GError **error) + return gplugin_plugin_info_new( + "gplugin/test-newest-version/solo-non-semantic", +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) +G_MODULE_EXPORT gboolean + G_GNUC_UNUSED GPluginNativePlugin *plugin, + G_GNUC_UNUSED GError **error) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gplugin/tests/test-newest-version.c Sun Apr 12 02:45:51 2020 -0500
@@ -0,0 +1,117 @@
+ * Copyright (C) 2011-2020 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 2 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/>. +/****************************************************************************** + *****************************************************************************/ +test_newest_version(const gchar *id, const gchar *version) + GPluginPlugin *plugin = NULL; + GPluginPluginInfo *info = NULL; + gplugin_manager_append_path(TEST_DIR); + gplugin_manager_refresh(); + plugin = gplugin_manager_find_plugin_with_newest_version(id); + g_assert_nonnull(plugin); + g_assert_true(GPLUGIN_IS_PLUGIN(plugin)); + info = gplugin_plugin_get_info(plugin); + g_assert_nonnull(info); + g_assert_true(GPLUGIN_IS_PLUGIN_INFO(info)); + g_assert_cmpstr(gplugin_plugin_info_get_version(info), ==, version); + g_clear_object(&plugin); +/****************************************************************************** + *****************************************************************************/ +test_newest_version_multiple_semantic(void) + "gplugin/test-newest-version/multiple-semantic", +test_newest_version_solo_non_semantic(void) + "gplugin/test-newest-version/solo-non-semantic", +test_newest_version_non_semantic_and_semantic(void) + "gplugin/test-newest-version/non-semantic-and-semantic", +test_newest_version_solo_no_version(void) + test_newest_version("gplugin/test-newest-version/solo-no-version", NULL); +test_newest_version_no_version_and_semantic(void) + "gplugin/test-newest-version/no-version-and-semantic", +/****************************************************************************** + *****************************************************************************/ +main(gint argc, gchar **argv) + g_test_init(&argc, &argv, NULL); + "/manager/find_plugin_newest_version/multiple-semantic", + test_newest_version_multiple_semantic); + "/manager/find_plugin_newest_version/no-version-and-semantic", + test_newest_version_no_version_and_semantic); + "/manager/find_plugin_newest_version/non-semantic-and-semantic", + test_newest_version_non_semantic_and_semantic); + "/manager/find_plugin_newest_version/solo-no-version", + test_newest_version_solo_no_version); + "/manager/find_plugin_newest_version/solo-non-semantic", + test_newest_version_solo_non_semantic); --- a/gplugin/tests/test-version-compare.c Sun Apr 12 01:27:32 2020 +0000
+++ b/gplugin/tests/test-version-compare.c Sun Apr 12 02:45:51 2020 -0500
@@ -22,185 +22,128 @@
*****************************************************************************/
-test_gplugin_version_null__null_subprocess(void)
- gplugin_version_compare(NULL, NULL, NULL);
test_gplugin_version_null__null(void)
- g_test_trap_subprocess("/version-compare/null__null/subprocess", 0, 0);
- g_test_trap_assert_failed();
- g_test_trap_assert_stderr("*gplugin_version_compare*assertion*");
-test_gplugin_version_null__1_2_3_subprocess(void)
- gplugin_version_compare(NULL, "1.2.3", NULL);
+ g_assert_cmpint(gplugin_version_compare(NULL, NULL), ==, 0); test_gplugin_version_null__1_2_3(void)
- g_test_trap_subprocess("/version-compare/null__1_2_3/subprocess", 0, 0);
- g_test_trap_assert_failed();
- g_test_trap_assert_stderr("*gplugin_version_compare*assertion*");
-test_gplugin_version_1_2_3__null_subprocess(void)
- gplugin_version_compare("1.2.3", NULL, NULL);
+ g_assert_cmpint(gplugin_version_compare(NULL, "1.2.3"), <, 0); test_gplugin_version_1_2_3__null(void)
- g_test_trap_subprocess("/version-compare/1_2_3__null/subprocess", 0, 0);
- g_test_trap_assert_failed();
- g_test_trap_assert_stderr("*gplugin_version_compare*assertion*");
-test_gplugin_version_abc__1_2_3_subprocess(void)
- t = gplugin_version_compare("abc", "1.2.3", &error);
- g_assert_cmpint(t, ==, 1);
- g_assert_no_error(error);
+ g_assert_cmpint(gplugin_version_compare("1.2.3", NULL), >, 0); test_gplugin_version_abc__1_2_3(void)
- g_test_trap_subprocess("/version-compare/abc__1_2_3/subprocess", 0, 0);
- g_test_trap_assert_failed();
- g_test_trap_assert_stderr("*assertion*");
-test_gplugin_version_1_2_3__abc_subprocess(void)
- t = gplugin_version_compare("1.2.3", "abc", &error);
- g_assert_cmpint(t, ==, -1);
- g_assert_no_error(error);
+ g_assert_cmpint(gplugin_version_compare("abc", "1.2.3"), <, 0); test_gplugin_version_1_2_3__abc(void)
- g_test_trap_subprocess("/version-compare/1_2_3__abc/subprocess", 0, 0);
- g_test_trap_assert_failed();
- g_test_trap_assert_stderr("*assertion*");
+ g_assert_cmpint(gplugin_version_compare("1.2.3", "abc"), >, 0); /* major version tests */
test_gplugin_version_1_0_0__0_0_0(void)
- g_assert_cmpint(gplugin_version_compare("1.0.0", "0.0.0", NULL), >, 0);
+ g_assert_cmpint(gplugin_version_compare("1.0.0", "0.0.0"), >, 0); test_gplugin_version_1_0_0__1_0_0(void)
- g_assert_cmpint(gplugin_version_compare("1.0.0", "1.0.0", NULL), ==, 0);
+ g_assert_cmpint(gplugin_version_compare("1.0.0", "1.0.0"), ==, 0); test_gplugin_version_0_0_0__1_0_0(void)
- g_assert_cmpint(gplugin_version_compare("0.0.0", "1.0.0", NULL), <, 0);
+ g_assert_cmpint(gplugin_version_compare("0.0.0", "1.0.0"), <, 0); /* minor version tests */
test_gplugin_version_0_1_0__0_0_0(void)
- g_assert_cmpint(gplugin_version_compare("0.1.0", "0.0.0", NULL), >, 0);
+ g_assert_cmpint(gplugin_version_compare("0.1.0", "0.0.0"), >, 0); test_gplugin_version_0_1_0__0_1_0(void)
- g_assert_cmpint(gplugin_version_compare("0.1.0", "0.1.0", NULL), ==, 0);
+ g_assert_cmpint(gplugin_version_compare("0.1.0", "0.1.0"), ==, 0); test_gplugin_version_0_0_0__0_1_0(void)
- g_assert_cmpint(gplugin_version_compare("0.0.0", "0.1.0", NULL), <, 0);
+ g_assert_cmpint(gplugin_version_compare("0.0.0", "0.1.0"), <, 0); /* micro version tests */
test_gplugin_version_0_0_1__0_0_0(void)
- g_assert_cmpint(gplugin_version_compare("0.0.1", "0.0.0", NULL), >, 0);
+ g_assert_cmpint(gplugin_version_compare("0.0.1", "0.0.0"), >, 0); test_gplugin_version_0_0_1__0_0_1(void)
- g_assert_cmpint(gplugin_version_compare("0.0.1", "0.0.1", NULL), ==, 0);
+ g_assert_cmpint(gplugin_version_compare("0.0.1", "0.0.1"), ==, 0); test_gplugin_version_0_0_0__0_0_1(void)
- g_assert_cmpint(gplugin_version_compare("0.0.0", "0.0.1", NULL), <, 0);
+ g_assert_cmpint(gplugin_version_compare("0.0.0", "0.0.1"), <, 0); test_gplugin_version_1_0__0_1(void)
- g_assert_cmpint(gplugin_version_compare("1.0", "0.1", NULL), >, 0);
+ g_assert_cmpint(gplugin_version_compare("1.0", "0.1"), >, 0); test_gplugin_version_1_0__1_0(void)
- g_assert_cmpint(gplugin_version_compare("1.0", "1.0", NULL), ==, 0);
+ g_assert_cmpint(gplugin_version_compare("1.0", "1.0"), ==, 0); test_gplugin_version_0_1__1_0(void)
- g_assert_cmpint(gplugin_version_compare("0.1", "1.0", NULL), <, 0);
+ g_assert_cmpint(gplugin_version_compare("0.1", "1.0"), <, 0); test_gplugin_version_1__0(void)
- g_assert_cmpint(gplugin_version_compare("1", "0", NULL), >, 0);
+ g_assert_cmpint(gplugin_version_compare("1", "0"), >, 0); test_gplugin_version_1__1(void)
- g_assert_cmpint(gplugin_version_compare("1", "1", NULL), ==, 0);
+ g_assert_cmpint(gplugin_version_compare("1", "1"), ==, 0); test_gplugin_version_0__1(void)
- g_assert_cmpint(gplugin_version_compare("0", "1", NULL), <, 0);
+ g_assert_cmpint(gplugin_version_compare("0", "1"), <, 0); /******************************************************************************
@@ -229,21 +172,6 @@
"/version-compare/1_2_3__abc",
test_gplugin_version_1_2_3__abc);
- "/version-compare/null__null/subprocess",
- test_gplugin_version_null__null_subprocess);
- "/version-compare/null__1_2_3/subprocess",
- test_gplugin_version_null__1_2_3_subprocess);
- "/version-compare/1_2_3__null/subprocess",
- test_gplugin_version_1_2_3__null_subprocess);
- "/version-compare/abc__1_2_3/subprocess",
- test_gplugin_version_abc__1_2_3_subprocess);
- "/version-compare/1_2_3__abc/subprocess",
- test_gplugin_version_1_2_3__abc_subprocess);