blob: 3a744449bf74fb245e029cf0319087393a7d23d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include <libaksettings.h>
#include <libaklog.h>
#include <stdio.h>
int test_ak_settings_read_write_example()
{
printf("Testing: %s\n", __func__);
if (!ak_settings_load_settings_binary())
{
ak_log_warning(__func__, "No existing settings or error loading.\n");
}
ak_settings_set_setting("username", "john_doe");
ak_settings_set_setting("theme", "dark");
ak_settings_set_setting("volume", "75");
ak_settings_set_setting("theme", "light");
if (!ak_settings_save_settings_binary())
{
printf("Error saving settings!\n");
ak_settings_free_settings();
return 1;
}
const char *theme = ak_settings_get_setting("theme");
if (theme)
{
char *some_text;
asprintf(&some_text, "Current theme: %s\n", theme);
ak_log_info(__func__, some_text);
}
ak_settings_free_settings();
return 0;
}
int test_ak_settings()
{
char *some_text;
if ( test_ak_settings_read_write_example() == 0 )
{
asprintf(&some_text, "Passed test");
ak_log_info(__func__, some_text);
return 0;
}
else
{
asprintf(&some_text, "Failed test");
ak_log_error(__func__, some_text);
return 1;
}
}
int main()
{
return test_ak_settings();
}
|