Mon, 18 May 2015 18:39:19 +0200
added free() to AVL tree implementation + use UcxAllocator
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
1 | /* |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
3 | * |
192
1e51558b9d09
updated copyright notice + added files for upcoming AVL tree implementation
Mike Becker <universe@uap-core.de>
parents:
177
diff
changeset
|
4 | * Copyright 2015 Olaf Wintermann. All rights reserved. |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
5 | * |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
6 | * Redistribution and use in source and binary forms, with or without |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
7 | * modification, are permitted provided that the following conditions are met: |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
8 | * |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
9 | * 1. Redistributions of source code must retain the above copyright |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
10 | * notice, this list of conditions and the following disclaimer. |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
11 | * |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
12 | * 2. Redistributions in binary form must reproduce the above copyright |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
13 | * notice, this list of conditions and the following disclaimer in the |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
14 | * documentation and/or other materials provided with the distribution. |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
15 | * |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
26 | * POSSIBILITY OF SUCH DAMAGE. |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
27 | */ |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
28 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
29 | #include "prop_tests.h" |
147
1aa598f36872
added printf for UcxBuffer + fixed memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
30 | #include "ucx/mempool.h" |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
31 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
110
diff
changeset
|
32 | UCX_TEST(test_ucx_properties_new) { |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
33 | UcxProperties *parser = ucx_properties_new(); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
34 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
35 | UCX_TEST_BEGIN |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
36 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
37 | UCX_TEST_ASSERT(parser != NULL, "failed"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
38 | UCX_TEST_ASSERT(parser->buffer == NULL, "parser has buffer"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
39 | UCX_TEST_ASSERT(parser->tmp == NULL, "parser has tmp buffer"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
40 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
41 | UCX_TEST_END |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
42 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
43 | ucx_properties_free(parser); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
44 | } |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
45 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
110
diff
changeset
|
46 | UCX_TEST(test_ucx_properties_next) { |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
47 | const char *tests[] = { |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
48 | "name = value\n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
49 | "name=value\n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
50 | "n=value\n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
51 | "name=v\n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
52 | "n=v\n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
53 | "name = value # comment\n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
54 | "#comment\nn=v\n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
55 | "# comment1\n# comment2\n\n \n\nname = value\n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
56 | " name = value\n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
57 | "name = value\n\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
58 | }; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
59 | |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
60 | const char *names[] = { |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
61 | "name", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
62 | "name", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
63 | "n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
64 | "name", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
65 | "n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
66 | "name", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
67 | "n", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
68 | "name", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
69 | "name", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
70 | "name" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
71 | }; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
72 | |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
73 | const char *values[] = { |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
74 | "value", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
75 | "value", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
76 | "value", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
77 | "v", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
78 | "v", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
79 | "value", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
80 | "v", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
81 | "value", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
82 | "value", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
83 | "value" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
84 | }; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
85 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
86 | UCX_TEST_BEGIN |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
87 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
88 | sstr_t name; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
89 | sstr_t value; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
90 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
91 | for(int i=0;i<10;i++) { |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
92 | UcxProperties *parser = ucx_properties_new(); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
93 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
94 | ucx_properties_fill(parser, (char*)tests[i], strlen(tests[i])); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
95 | UCX_TEST_ASSERT(parser->buffer == tests[i], "fill failed"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
96 | UCX_TEST_ASSERT(parser->buflen == strlen(tests[i]), "wrong buflen"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
97 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
98 | int r = ucx_properties_next(parser, &name, &value); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
99 | sstr_t n = sstr((char*)names[i]); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
100 | sstr_t v = sstr((char*)values[i]); |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
101 | UCX_TEST_ASSERT(r == 1, "next returned 0"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
102 | UCX_TEST_ASSERT((!sstrcmp(name, n)), "wrong property name"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
103 | UCX_TEST_ASSERT((!sstrcmp(value, v)), "wrong property value"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
104 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
105 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
106 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
107 | UCX_TEST_ASSERT(parser->tmp == NULL, "tmp not NULL"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
108 | UCX_TEST_ASSERT(parser->tmpcap == 0, "tmpcap not NULL"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
109 | UCX_TEST_ASSERT(parser->tmplen == 0, "tmplen not NULL"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
110 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
111 | ucx_properties_free(parser); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
112 | } |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
113 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
114 | UCX_TEST_END |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
115 | } |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
116 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
110
diff
changeset
|
117 | UCX_TEST(test_ucx_properties_next_multi) { |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
118 | const char *names[] = { |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
119 | "a", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
120 | "b", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
121 | "c", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
122 | "uap", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
123 | "name", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
124 | "key1", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
125 | "key2", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
126 | "key3" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
127 | }; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
128 | |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
129 | const char *values[] = { |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
130 | "a value", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
131 | "b value", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
132 | "core", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
133 | "core", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
134 | "ucx", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
135 | "value1", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
136 | "value2", |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
137 | "value3" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
138 | }; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
139 | |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
140 | const char *str = "#\n" |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
141 | "# properties\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
142 | "# contains key/value pairs\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
143 | "#\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
144 | "a = a value\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
145 | "b = b value\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
146 | "c = core\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
147 | "\n# test\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
148 | "uap = core\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
149 | "name = ucx\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
150 | "# no = property\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
151 | "key1 = value1\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
152 | "#key1 = wrong value\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
153 | "#key2 = not value 2\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
154 | "key2 = value2\n" |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
155 | "\n\n\n \n key3=value3\n"; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
156 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
157 | UcxProperties *parser = ucx_properties_new(); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
158 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
159 | UCX_TEST_BEGIN |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
160 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
161 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
162 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
163 | sstr_t name; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
164 | sstr_t value; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
165 | for(int i=0;i<8;i++) { |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
166 | int r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
167 | UCX_TEST_ASSERT(r == 1, "next returned 0"); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
168 | UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)names[i]))), "wrong name"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
169 | UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)values[i]))), |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
170 | "wrong value"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
171 | } |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
172 | int r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
173 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
174 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
175 | UCX_TEST_END |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
176 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
177 | ucx_properties_free(parser); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
178 | } |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
179 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
110
diff
changeset
|
180 | UCX_TEST(test_ucx_properties_next_part) { |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
181 | UcxProperties *parser = ucx_properties_new(); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
182 | const char *str; |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
183 | int r; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
184 | sstr_t name; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
185 | sstr_t value; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
186 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
187 | UCX_TEST_BEGIN |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
188 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
189 | str = ""; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
190 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
191 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
192 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
193 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
194 | str = " \n"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
195 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
196 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
197 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
198 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
199 | str = "name"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
200 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
201 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
202 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
203 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
204 | str = " "; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
205 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
206 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
207 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
208 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
209 | str = "= "; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
210 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
211 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
212 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
213 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
214 | str = "value"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
215 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
216 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
217 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
218 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
219 | str = "\n"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
220 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
221 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
222 | UCX_TEST_ASSERT(r == 1, "next returned 0"); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
223 | UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"name"))), "wrong name"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
224 | UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)"value"))), "wrong value"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
225 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
226 | // second round |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
227 | str = "#comment\n"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
228 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
229 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
230 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
231 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
232 | str = "#comment\nname = "; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
233 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
234 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
235 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
236 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
237 | str = "value\na = b\n"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
238 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
239 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
240 | UCX_TEST_ASSERT(r == 1, "next returned 0"); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
241 | UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"name"))), "wrong name"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
242 | UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)"value"))), "wrong value"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
243 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
244 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
245 | UCX_TEST_ASSERT(r == 1, "next returned 0"); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
246 | UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"a"))), "wrong name"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
247 | UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)"b"))), "wrong value"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
248 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
249 | str = "# comment\n#\n#\ntests = "; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
250 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
251 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
252 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
253 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
254 | str = "test1 "; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
255 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
256 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
257 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
258 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
259 | str = "test2 test3 test4\n"; |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
260 | sstr_t testv = sstr((char*)"test1 test2 test3 test4"); |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
261 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
262 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
263 | UCX_TEST_ASSERT(r == 1, "next returned 0"); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
264 | UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"tests"))), "wrong name"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
265 | UCX_TEST_ASSERT((!sstrcmp(value, testv)), "wrong value"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
266 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
267 | // test if ucx_properties_next finds a name/value after a tmp comment |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
268 | str = "# just a comment"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
269 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
270 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
271 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
272 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
273 | str = " in 3"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
274 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
275 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
276 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
277 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
278 | str = " parts\na = 1\n"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
279 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
280 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
281 | UCX_TEST_ASSERT(r == 1, "next returned 0"); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
282 | UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"a"))), "wrong name"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
283 | UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)"1"))), "wrong value"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
284 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
285 | UCX_TEST_END |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
286 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
287 | ucx_properties_free(parser); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
288 | } |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
289 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
110
diff
changeset
|
290 | UCX_TEST(test_ucx_properties_next_long) { |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
291 | UcxProperties *parser = ucx_properties_new(); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
292 | int r; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
293 | size_t name_len = 512; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
294 | char *long_name = (char*)malloc(name_len); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
295 | memset(long_name, 'a', 70); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
296 | memset(long_name+70, 'b', 242); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
297 | memset(long_name+312, 'c', 200); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
298 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
299 | size_t value_len = 2048; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
300 | char *long_value = (char*)malloc(value_len); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
301 | memset(long_value, 'x', 1024); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
302 | memset(long_value+1024, 'y', 1024); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
303 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
304 | UCX_TEST_BEGIN |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
305 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
306 | sstr_t name; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
307 | sstr_t value; |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
308 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
309 | ucx_properties_fill(parser, long_name, 10); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
310 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
311 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
312 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
313 | ucx_properties_fill(parser, long_name+10, 202); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
314 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
315 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
316 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
317 | ucx_properties_fill(parser, long_name+212, 200); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
318 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
319 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
320 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
321 | ucx_properties_fill(parser, long_name+412, 100); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
322 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
323 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
324 | |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
325 | const char *str = " = "; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
326 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
327 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
328 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
329 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
330 | ucx_properties_fill(parser, long_value, 512); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
331 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
332 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
333 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
334 | ucx_properties_fill(parser, long_value+512, 1024); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
335 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
336 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
337 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
338 | ucx_properties_fill(parser, long_value+1536, 512); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
339 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
340 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
341 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
342 | str = "\n#comment\nkey = value\n"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
343 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
344 | r = ucx_properties_next(parser, &name, &value); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
345 | sstr_t n = sstrn(long_name, name_len); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
346 | sstr_t v = sstrn(long_value, value_len); |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
347 | UCX_TEST_ASSERT(r == 1, "next returned 0"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
348 | UCX_TEST_ASSERT((!sstrcmp(name, n)), "wrong name"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
349 | UCX_TEST_ASSERT((!sstrcmp(value, v)), "wrong value"); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
350 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
351 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
352 | UCX_TEST_ASSERT(r == 1, "next returned 0"); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
353 | UCX_TEST_ASSERT((!sstrcmp(name, sstr((char*)"key"))), "wrong name"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
354 | UCX_TEST_ASSERT((!sstrcmp(value, sstr((char*)"value"))), "wrong value"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
355 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
356 | r = ucx_properties_next(parser, &name, &value); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
357 | UCX_TEST_ASSERT(r == 0, "next returned 1"); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
358 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
359 | UCX_TEST_END |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
360 | |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
361 | free(long_name); |
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
362 | free(long_value); |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
363 | ucx_properties_free(parser); |
108
d2b1e67b2b48
new properties parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff
changeset
|
364 | } |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
365 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
110
diff
changeset
|
366 | UCX_TEST(test_ucx_properties2map) { |
147
1aa598f36872
added printf for UcxBuffer + fixed memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
367 | UcxMempool *mp = ucx_mempool_new(64); |
158
81d580042da1
Added allocator to mempool struct + fixed suncc.mk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
368 | UcxMap *map = ucx_map_new_a(mp->allocator, 16); |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
369 | UcxProperties *parser = ucx_properties_new(); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
370 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
371 | UCX_TEST_BEGIN |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
372 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
373 | const char *str = "key1 = value1\nkey2 = value2\n\n#comment\n\nkey3 = value3\n"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
374 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
375 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
376 | int r = ucx_properties2map(parser, map); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
377 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
378 | UCX_TEST_ASSERT(r == 0, "properties2map failed"); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
379 | UCX_TEST_ASSERT(map->count == 3, "wrong number of properties"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
380 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
381 | char *v1 = (char*)ucx_map_cstr_get(map, "key1"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
382 | char *v2 = (char*)ucx_map_cstr_get(map, "key2"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
383 | char *v3 = (char*)ucx_map_cstr_get(map, "key3"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
384 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
385 | UCX_TEST_ASSERT(v1, "value for key1 not found"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
386 | UCX_TEST_ASSERT(v2, "value for key2 not found"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
387 | UCX_TEST_ASSERT(v3, "value for key3 not found"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
388 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
389 | UCX_TEST_ASSERT((!strcmp(v1, "value1")), "wrong value for key1"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
390 | UCX_TEST_ASSERT((!strcmp(v2, "value2")), "wrong value for key2"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
391 | UCX_TEST_ASSERT((!strcmp(v3, "value3")), "wrong value for key3"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
392 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
393 | // second test |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
394 | ucx_map_free(map); |
158
81d580042da1
Added allocator to mempool struct + fixed suncc.mk
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
147
diff
changeset
|
395 | map = ucx_map_new_a(mp->allocator, 16); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
396 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
397 | str = "\n#comment\n"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
398 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
399 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
400 | r = ucx_properties2map(parser, map); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
401 | UCX_TEST_ASSERT(r == 0, "properties2map failed"); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
402 | UCX_TEST_ASSERT(map->count == 0, "wrong number of properties"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
403 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
404 | str = "key1 = value1\nsyntax error line\n"; |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
405 | ucx_properties_fill(parser, (char*)str, strlen(str)); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
406 | |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
407 | r = ucx_properties2map(parser, map); |
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
408 | UCX_TEST_ASSERT(r == 1, "properties2map should return 1"); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
409 | UCX_TEST_ASSERT(map->count == 1, "wrong number of properties"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
410 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
411 | char *v = (char*)ucx_map_cstr_get(map, "key1"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
412 | UCX_TEST_ASSERT((!strcmp(v, "value1")), "wrong value"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
413 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
414 | UCX_TEST_END |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
415 | |
147
1aa598f36872
added printf for UcxBuffer + fixed memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
416 | ucx_mempool_destroy(mp); |
110
1cf71e56f01e
renamed properties functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
109
diff
changeset
|
417 | ucx_properties_free(parser); |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
418 | } |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
419 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
110
diff
changeset
|
420 | UCX_TEST(test_ucx_properties_load) { |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
421 | UCX_TEST_BEGIN |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
422 | FILE *f = tmpfile(); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
423 | UCX_TEST_ASSERT(f, "test file cannot be opened, test aborted"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
424 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
425 | fprintf(f, "# properties file\n\nkey1 = value1\nkey2 = value2\n"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
426 | fprintf(f, "\n\nkey3 = value3\n\n"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
427 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
428 | size_t name_len = 512; |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
429 | char *long_name = (char*)malloc(name_len); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
430 | memset(long_name, 'k', 512); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
431 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
432 | size_t value_len = 2048; |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
433 | char *long_value = (char*)malloc(value_len); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
434 | memset(long_value, 'v', 2048); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
435 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
436 | fwrite(long_name, 1, name_len, f); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
437 | fprintf(f, " = "); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
438 | fwrite(long_value, 1, value_len, f); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
439 | fprintf(f, " \n"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
440 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
441 | fprintf(f, "\n\n\n\nlast_key = property value\n"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
442 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
443 | fflush(f); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
444 | fseek(f, 0, SEEK_SET); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
445 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
446 | UcxMap *map = ucx_map_new(8); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
447 | int r = ucx_properties_load(map, f); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
448 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
449 | UCX_TEST_ASSERT(r == 0, "ucx_properties_load failed"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
450 | UCX_TEST_ASSERT(map->count == 5, "wrong number of properties"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
451 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
452 | char *v1 = (char*)ucx_map_cstr_get(map, "key1"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
453 | char *v2 = (char*)ucx_map_cstr_get(map, "key2"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
454 | char *v3 = (char*)ucx_map_cstr_get(map, "key3"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
455 | char *lv = (char*)ucx_map_sstr_get(map, sstrn(long_name, name_len)); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
456 | char *lk = (char*)ucx_map_cstr_get(map, "last_key"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
457 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
458 | UCX_TEST_ASSERT(v1, "value for key1 not found"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
459 | UCX_TEST_ASSERT(v2, "value for key2 not found"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
460 | UCX_TEST_ASSERT(v3, "value for key3 not found"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
461 | UCX_TEST_ASSERT(lv, "value for long key not found"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
462 | UCX_TEST_ASSERT(lk, "value for last_key not found"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
463 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
464 | UCX_TEST_ASSERT((!strcmp(v1, "value1")), "wrong value for key1"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
465 | UCX_TEST_ASSERT((!strcmp(v2, "value2")), "wrong value for key2"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
466 | UCX_TEST_ASSERT((!strcmp(v3, "value3")), "wrong value for key3"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
467 | sstr_t long1 = sstrn(long_value, value_len); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
468 | sstr_t long2 = sstr(lv); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
469 | UCX_TEST_ASSERT((!sstrcmp(long1, long2)), "wrong value for long key"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
470 | UCX_TEST_ASSERT(!strcmp(lk, "property value"), "wrong value for last_key"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
471 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
472 | free(v1); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
473 | free(v2); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
474 | free(v3); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
475 | free(lv); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
476 | free(lk); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
477 | ucx_map_free(map); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
478 | fclose(f); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
479 | |
147
1aa598f36872
added printf for UcxBuffer + fixed memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
480 | free(long_name); |
1aa598f36872
added printf for UcxBuffer + fixed memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
481 | free(long_value); |
1aa598f36872
added printf for UcxBuffer + fixed memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
134
diff
changeset
|
482 | |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
483 | UCX_TEST_END |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
484 | } |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
485 | |
134
4d320dc3a7af
documented test.h and removed duplicated implement/declare macros for UCX_TEST
Mike Becker <universe@uap-core.de>
parents:
110
diff
changeset
|
486 | UCX_TEST(test_ucx_properties_store) { |
109
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
487 | UcxMap *map1 = ucx_map_new(16); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
488 | ucx_map_cstr_put(map1, "key1", "value1"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
489 | ucx_map_cstr_put(map1, "key2", "value2"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
490 | ucx_map_cstr_put(map1, "key3", "value3"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
491 | ucx_map_cstr_put(map1, "key4", "value4"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
492 | ucx_map_cstr_put(map1, "property.key1", "some value 1"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
493 | ucx_map_cstr_put(map1, "property.key2", "some value 2"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
494 | ucx_map_cstr_put(map1, "property.key3", "some value 3"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
495 | ucx_map_cstr_put(map1, "property.key4", "some value 4"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
496 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
497 | UCX_TEST_BEGIN |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
498 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
499 | FILE *f = tmpfile(); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
500 | fprintf(f, "#\n# test property file\n#\n#\n"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
501 | ucx_properties_store(map1, f); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
502 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
503 | fflush(f); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
504 | fseek(f, 0, SEEK_SET); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
505 | UcxMap *map2 = ucx_map_new(16); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
506 | ucx_properties_load(map2, f); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
507 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
508 | UCX_TEST_ASSERT(map2->count == 8, "wrong number of properties in map2"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
509 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
510 | char *v1 = (char*)ucx_map_cstr_get(map2, "key1"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
511 | char *v2 = (char*)ucx_map_cstr_get(map2, "key2"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
512 | char *v3 = (char*)ucx_map_cstr_get(map2, "key3"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
513 | char *v4 = (char*)ucx_map_cstr_get(map2, "key4"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
514 | char *v5 = (char*)ucx_map_cstr_get(map2, "property.key1"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
515 | char *v6 = (char*)ucx_map_cstr_get(map2, "property.key2"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
516 | char *v7 = (char*)ucx_map_cstr_get(map2, "property.key3"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
517 | char *v8 = (char*)ucx_map_cstr_get(map2, "property.key4"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
518 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
519 | UCX_TEST_ASSERT(v1 && v2 && v3 && v4 && v5 && v6 && v7 && v8, |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
520 | "missing values"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
521 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
522 | UCX_TEST_ASSERT((!strcmp(v1, "value1")), "wrong value 1"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
523 | UCX_TEST_ASSERT((!strcmp(v2, "value2")), "wrong value 2"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
524 | UCX_TEST_ASSERT((!strcmp(v3, "value3")), "wrong value 3"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
525 | UCX_TEST_ASSERT((!strcmp(v4, "value4")), "wrong value 4"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
526 | UCX_TEST_ASSERT((!strcmp(v5, "some value 1")), "wrong value 5"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
527 | UCX_TEST_ASSERT((!strcmp(v6, "some value 2")), "wrong value 6"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
528 | UCX_TEST_ASSERT((!strcmp(v7, "some value 3")), "wrong value 7"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
529 | UCX_TEST_ASSERT((!strcmp(v8, "some value 4")), "wrong value 8"); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
530 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
531 | free(v1); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
532 | free(v2); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
533 | free(v3); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
534 | free(v4); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
535 | free(v5); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
536 | free(v6); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
537 | free(v7); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
538 | free(v8); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
539 | ucx_map_free(map2); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
540 | fclose(f); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
541 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
542 | UCX_TEST_END |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
543 | |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
544 | ucx_map_free(map1); |
75cb6590358b
added properties load/store functions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
108
diff
changeset
|
545 | } |