ocarina/tests/gui/settings.c
Anna Schumaker 9e0f017e61 core/file: Build in minimum version checks
I don't think it makes sense that callers of file_open() are expected to
check the file version after opening.  This should be something handled
by the file code so we can print a consistent error message.

Implements issue #5: Better file versioning
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
2016-06-24 10:50:37 -04:00

55 lines
1.8 KiB
C

/*
* Copyright 2015 (c) Anna Schumaker.
*/
#include <core/file.h>
#include <gui/settings.h>
#include <tests/test.h>
static void test_settings()
{
struct file f = FILE_INIT("settings", 0, 0);
test_equal((void *)test_get_gui_settings(), NULL);
gui_settings_set("test.value1", 42);
gui_settings_set("test.value2", 84);
test_equal(gui_settings_has("test.value1"), (bool)false);
test_equal(gui_settings_get("test.value1"), 0);
test_equal(gui_settings_get("test.value2"), 0);
test_equal(file_exists(&f), (bool)false);
gui_settings_init();
test_not_equal((void *)test_get_gui_settings(), NULL);
test_equal(gui_settings_has("test.value1"), (bool)false);
gui_settings_set("test.value1", 42);
test_equal(gui_settings_has("test.value1"), (bool)true);
test_equal(gui_settings_has("test.value2"), (bool)false);
test_equal(file_exists(&f), (bool)true);
gui_settings_set("test.value2", 84);
test_equal(gui_settings_has("test.value2"), (bool)true);
test_equal(gui_settings_get("test.value1"), 42);
test_equal(gui_settings_get("test.value2"), 84);
gui_settings_deinit();
test_equal((void *)test_get_gui_settings(), NULL);
gui_settings_set("test.value1", 42);
gui_settings_set("test.value2", 84);
test_equal(gui_settings_get("test.value1"), 0);
test_equal(gui_settings_get("test.value2"), 0);
test_equal(gui_settings_has("test.value1"), (bool)false);
test_equal(gui_settings_has("test.value2"), (bool)false);
test_equal(file_exists(&f), (bool)true);
gui_settings_init();
test_not_equal((void *)test_get_gui_settings(), NULL);
test_equal(gui_settings_get("test.value1"), 42);
test_equal(gui_settings_get("test.value2"), 84);
test_equal(gui_settings_has("test.value1"), (bool)true);
test_equal(gui_settings_has("test.value2"), (bool)true);
gui_settings_deinit();
}
DECLARE_UNIT_TESTS(
UNIT_TEST("Settings", test_settings),
);