Mercurial > molko
comparison tests/test-save.c @ 84:a6c2067709ce
core: implement basic save routines, closes #2476 @2h
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sat, 07 Mar 2020 17:06:01 +0100 |
parents | |
children | 789b23e01f52 |
comparison
equal
deleted
inserted
replaced
83:f5d3e469eb93 | 84:a6c2067709ce |
---|---|
1 /* | |
2 * test-save.c -- test save routines | |
3 * | |
4 * Copyright (c) 2020 David Demelier <markand@malikania.fr> | |
5 * | |
6 * Permission to use, copy, modify, and/or distribute this software for any | |
7 * purpose with or without fee is hereby granted, provided that the above | |
8 * copyright notice and this permission notice appear in all copies. | |
9 * | |
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 #include <stdio.h> | |
20 | |
21 #include <greatest.h> | |
22 | |
23 #include "save.h" | |
24 | |
25 #define NAME "test.db" | |
26 | |
27 static void | |
28 clean(void *data) | |
29 { | |
30 (void)data; | |
31 | |
32 save_finish(); | |
33 remove(NAME); | |
34 } | |
35 | |
36 TEST | |
37 properties_simple(void) | |
38 { | |
39 ASSERT(save_open_path(NAME)); | |
40 | |
41 /* Insert a new property 'initialized'. */ | |
42 ASSERT(save_set_property("initialized", "1")); | |
43 ASSERT_STR_EQ(save_get_property("initialized"), "1"); | |
44 | |
45 /* This must replace the existing value. */ | |
46 ASSERT(save_set_property("initialized", "2")); | |
47 ASSERT_STR_EQ(save_get_property("initialized"), "2"); | |
48 | |
49 ASSERT(save_remove_property("initialized")); | |
50 ASSERT(!save_get_property("initialized")); | |
51 | |
52 PASS(); | |
53 } | |
54 | |
55 SUITE(properties) | |
56 { | |
57 SET_TEARDOWN(clean, NULL); | |
58 RUN_TEST(properties_simple); | |
59 } | |
60 | |
61 GREATEST_MAIN_DEFS(); | |
62 | |
63 int | |
64 main(int argc, char **argv) | |
65 { | |
66 GREATEST_MAIN_BEGIN(); | |
67 RUN_SUITE(properties); | |
68 GREATEST_MAIN_END(); | |
69 } |