tests: Add tests for automatic_version_prefix

This commit is contained in:
James Antill 2015-01-12 00:08:17 -05:00
parent f2d5369050
commit 8aeb1272f9

View File

@ -5,6 +5,7 @@
#include <glib-unix.h>
#include <libgsystem.h>
#include "rpmostree-json-parsing.h"
#include "rpmostree-util.h"
static const gchar *test_data =
"{ \"text\" : \"hello, world!\", \"foo\" : null, \"blah\" : 47, \"double\" : 42.47 }";
@ -46,6 +47,46 @@ test_get_optional_string_member (void)
json_object_unref (obj);
}
static void
test_auto_version (void)
{
char *version = NULL;
#define _VER_TST(x, y, z) \
version = _rpmostree_util_next_version ((x), (y)); \
g_assert_cmpstr (version, ==, z); \
g_free (version); \
version = NULL
_VER_TST("10", "", "10");
_VER_TST("10", "xyz", "10");
_VER_TST("10", "9", "10");
_VER_TST("10", "11", "10");
_VER_TST("10", "10", "10.1");
_VER_TST("10.1", "10.1", "10.1.1");
_VER_TST("10", "10.0", "10.1");
_VER_TST("10", "10.1", "10.2");
_VER_TST("10", "10.2", "10.3");
_VER_TST("10", "10.3", "10.4");
_VER_TST("10", "10.1.5", "10.2");
_VER_TST("10.1", "10.1.5", "10.1.6");
_VER_TST("10.1", "10.1.1.5", "10.1.2");
_VER_TST("10", "10001", "10");
_VER_TST("10", "101.1", "10");
_VER_TST("10", "10x.1", "10");
_VER_TST("10.1", "10", "10.1");
_VER_TST("10.1", "10.", "10.1");
_VER_TST("10.1", "10.0", "10.1");
_VER_TST("10.1", "10.2", "10.1");
_VER_TST("10.1", "10.12", "10.1");
_VER_TST("10.1", "10.1x", "10.1");
_VER_TST("10.1", "10.1.x", "10.1.1");
_VER_TST("10.1", "10.1.2x", "10.1.3");
}
int
main (int argc,
char *argv[])
@ -53,6 +94,7 @@ main (int argc,
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/jsonparsing/get-optional-member", test_get_optional_string_member);
g_test_add_func ("/versioning/automatic", test_auto_version);
return g_test_run ();
}