Go to the documentation of this file.
16 char v1_in[] =
"value1";
17 char v1_2_in[] =
"value1.2";
18 char v2_in[] =
"value2";
19 char v2_const_in[] =
"value3";
23 ck_assert_str_eq(v1_in, v1_out);
27 ck_assert_str_eq(v1_2_in, v1_2_out);
31 ck_assert_str_eq(v2_in, v2_out);
35 ck_assert_str_eq(v2_const_in, v2_const_out);
43 ck_assert(v2_const_out ==
NULL);
61 char *keys[] = {
"key1",
"key2",
"key3"};
62 char *
values[] = {
"value1",
"value2",
"value3"};
64 for (key_count = 0; key_count < 3; key_count++){
68 int replace_value = 0;
69 for (replace_value = 0; replace_value < 2; replace_value++){
73 for (rewind_count = 0; rewind_count < 3; rewind_count++){
77 for (
k=0;
k<key_count;
k++){
84 for (
k=0;
k<key_count;
k++){
91 for (
k=0;
k<key_count;
k++){
92 ck_assert_int_eq(found[
k], 1);
105 char *keys[] = {
"key1"};
106 char *
values[] = {
"value1"};
108 for (key_count = 0; key_count < 1; key_count++){
112 int replace_value = 0;
113 for (replace_value = 0; replace_value < 2; replace_value++){
116 int rewind_count = 0;
117 for (rewind_count = 0; rewind_count < 3; rewind_count++){
119 int found[key_count];
121 for (
k=0;
k<key_count;
k++){
128 for (
k=0;
k<key_count;
k++){
135 for (
k=0;
k<key_count;
k++){
136 ck_assert_int_eq(found[
k], 1);
149 char *keys[] = {
"key1",
"key2",
"key3"};
150 char *
values[] = {
"value1",
"value2",
"value3"};
152 for (key_count = 0; key_count < 3; key_count++){
156 int remove_value = 0;
157 for (remove_value = 0; remove_value < key_count-1; remove_value++){
161 int found[key_count];
163 for (
k=0;
k<key_count;
k++){
170 for (
k=0;
k<key_count;
k++){
177 for (;
k<key_count;
k++){
178 ck_assert_int_eq(found[
k], 1);
188 static const char characters[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
189 static void random_string(
char *buffer,
int length){
191 for (
i=0;
i<length;
i++){
192 buffer[
i] = characters[rand() % (
sizeof(characters)-1)];
198 int i,
j, contains_dupes,
count = 1000, length = 8;
199 char keys[
count][length+1];
203 random_string(keys[
i], length);
204 random_string(
values[
i], length);
205 keys[
i][length] =
'\0';
212 if (!strcmp(keys[
i], keys[
j])){
214 random_string(keys[
j], length);
218 }
while (contains_dupes);
232 Suite *
s = suite_create(
"Stub");
234 TCase *tc_core = tcase_create(
"Core");
235 tcase_add_test(tc_core, set_1);
236 tcase_add_test(tc_core, remove_1);
237 tcase_add_test(tc_core, iterating);
238 tcase_add_test(tc_core, iterating_one_value);
239 tcase_add_test(tc_core, stress_test);
240 suite_add_tcase(
s, tc_core);
242 TCase *tc_segfaults = tcase_create(
"Segfaults");
243 tcase_add_test(tc_segfaults, set_1);
244 tcase_add_test(tc_segfaults, get_out_of_scope);
245 tcase_add_test(tc_segfaults, set_out_of_scope);
246 suite_add_tcase(
s, tc_segfaults);
251 int main(
int argc,
char **argv){
255 SRunner *sr = srunner_create(
s);
257 srunner_run_all(sr, CK_VERBOSE);
258 number_failed = srunner_ntests_failed(sr);
260 return (number_failed == 0) ?
EXIT_SUCCESS : EXIT_FAILURE;
shash * shash_create(uint32_t options)
Initialize a shash object.
int shash_set(shash *h, const char *key, const char *value)
Add or overwrite a pointer, associating it with the given key.
Implementation-specific, generic type to store the shash object.
END_TEST Suite * stub_suite(void)
const char * shash_get(shash *h, const char *key)
Find a pointer associated with the given string.
int shash_next(shash *h, const char **key, const char **value)
Retrieves the next key-value pair in the shash. The order in which the pointers are returned shall be...
int shash_rewind(shash *h)
Rewind iterator for traversing all the keys and values.
HISTORY txt for MOD_PR01(step one of PGE01) History follows the following convention needed due to new Aqua ReprocessingActual and the expected LUT revision number from PCF Changed to use PGE version for ProductionHistory Added Archive including ProcessingEnvironment Corrected handling of bad to resovle GSFcd02514 Changed to check staged LUT revision number versus the expected LUT revision number from thereby resolving defect report MODxl02056 This change also avoids the memory access violation reported in MODur00039 Changed the way output arrays were initialized with fill values
A simple dictionary library for storing strings.
int main(int argc, char **argv)
int shash_destroy(shash *h)
Destroy a shash object, free'ing the memory used.
int shash_remove(shash *h, const char *key)
Remove a pointer associated with the given string.