tests: Build settings test with ctest
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
1710c8076a
commit
3e2ed7761c
|
@ -5,3 +5,4 @@ function(gui_unit_test name)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
gui_unit_test(Builder)
|
gui_unit_test(Builder)
|
||||||
|
gui_unit_test(Settings)
|
||||||
|
|
|
@ -25,7 +25,7 @@ def GuiTest(name):
|
||||||
|
|
||||||
env.UsePackage("gmodule-export-2.0")
|
env.UsePackage("gmodule-export-2.0")
|
||||||
gui_objs += [ env.Object("../../gui/builder.c") ]
|
gui_objs += [ env.Object("../../gui/builder.c") ]
|
||||||
res += [ GuiTest("settings") ]
|
gui_objs += [ env.Object("../../gui/settings.c") ]
|
||||||
res += [ GuiTest("model") ]
|
res += [ GuiTest("model") ]
|
||||||
res += [ GuiTest("view") ]
|
res += [ GuiTest("view") ]
|
||||||
res += [ GuiTest("queue") ]
|
res += [ GuiTest("queue") ]
|
||||||
|
|
|
@ -9,46 +9,49 @@ static void test_settings()
|
||||||
{
|
{
|
||||||
struct file f = FILE_INIT("settings", 0, 0);
|
struct file f = FILE_INIT("settings", 0, 0);
|
||||||
|
|
||||||
test_equal((void *)test_get_gui_settings(), NULL);
|
g_assert_null(test_get_gui_settings());
|
||||||
gui_settings_set("test.value1", 42);
|
gui_settings_set("test.value1", 42);
|
||||||
gui_settings_set("test.value2", 84);
|
gui_settings_set("test.value2", 84);
|
||||||
test_equal(gui_settings_has("test.value1"), (bool)false);
|
g_assert_false(gui_settings_has("test.value1"));
|
||||||
test_equal(gui_settings_get("test.value1"), 0);
|
g_assert_cmpuint(gui_settings_get("test.value1"), ==, 0);
|
||||||
test_equal(gui_settings_get("test.value2"), 0);
|
g_assert_cmpuint(gui_settings_get("test.value2"), ==, 0);
|
||||||
test_equal(file_exists(&f), (bool)false);
|
g_assert_false(file_exists(&f));
|
||||||
|
|
||||||
gui_settings_init();
|
gui_settings_init();
|
||||||
test_not_equal((void *)test_get_gui_settings(), NULL);
|
g_assert_nonnull(test_get_gui_settings());
|
||||||
test_equal(gui_settings_has("test.value1"), (bool)false);
|
g_assert_false(gui_settings_has("test.value1"));
|
||||||
gui_settings_set("test.value1", 42);
|
gui_settings_set("test.value1", 42);
|
||||||
test_equal(gui_settings_has("test.value1"), (bool)true);
|
g_assert_true(gui_settings_has("test.value1"));
|
||||||
test_equal(gui_settings_has("test.value2"), (bool)false);
|
g_assert_false(gui_settings_has("test.value2"));
|
||||||
test_equal(file_exists(&f), (bool)true);
|
g_assert_true(file_exists(&f));
|
||||||
gui_settings_set("test.value2", 84);
|
gui_settings_set("test.value2", 84);
|
||||||
test_equal(gui_settings_has("test.value2"), (bool)true);
|
g_assert_true(gui_settings_has("test.value2"));
|
||||||
test_equal(gui_settings_get("test.value1"), 42);
|
g_assert_cmpuint(gui_settings_get("test.value1"), ==, 42);
|
||||||
test_equal(gui_settings_get("test.value2"), 84);
|
g_assert_cmpuint(gui_settings_get("test.value2"), ==, 84);
|
||||||
|
|
||||||
gui_settings_deinit();
|
gui_settings_deinit();
|
||||||
test_equal((void *)test_get_gui_settings(), NULL);
|
g_assert_null(test_get_gui_settings());
|
||||||
gui_settings_set("test.value1", 42);
|
gui_settings_set("test.value1", 42);
|
||||||
gui_settings_set("test.value2", 84);
|
gui_settings_set("test.value2", 84);
|
||||||
test_equal(gui_settings_get("test.value1"), 0);
|
g_assert_cmpuint(gui_settings_get("test.value1"), ==, 0);
|
||||||
test_equal(gui_settings_get("test.value2"), 0);
|
g_assert_cmpuint(gui_settings_get("test.value2"), ==, 0);
|
||||||
test_equal(gui_settings_has("test.value1"), (bool)false);
|
g_assert_false(gui_settings_has("test.value1"));
|
||||||
test_equal(gui_settings_has("test.value2"), (bool)false);
|
g_assert_false(gui_settings_has("test.value2"));
|
||||||
test_equal(file_exists(&f), (bool)true);
|
g_assert_true(file_exists(&f));
|
||||||
|
|
||||||
gui_settings_init();
|
gui_settings_init();
|
||||||
test_not_equal((void *)test_get_gui_settings(), NULL);
|
g_assert_nonnull(test_get_gui_settings());
|
||||||
test_equal(gui_settings_get("test.value1"), 42);
|
g_assert_cmpuint(gui_settings_get("test.value1"), ==, 42);
|
||||||
test_equal(gui_settings_get("test.value2"), 84);
|
g_assert_cmpuint(gui_settings_get("test.value2"), ==, 84);
|
||||||
test_equal(gui_settings_has("test.value1"), (bool)true);
|
g_assert_true(gui_settings_has("test.value1"));
|
||||||
test_equal(gui_settings_has("test.value2"), (bool)true);
|
g_assert_true(gui_settings_has("test.value2"));
|
||||||
|
|
||||||
gui_settings_deinit();
|
gui_settings_deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_UNIT_TESTS(
|
int main(int argc, char **argv)
|
||||||
UNIT_TEST("Settings", test_settings),
|
{
|
||||||
);
|
g_test_init(&argc, &argv, NULL);
|
||||||
|
g_test_add_func("/Gui/Settings", test_settings);
|
||||||
|
return g_test_run();
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue