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(v1_in == v1_out);
27 ck_assert(v1_2_in == v1_2_out);
31 ck_assert(v2_in == v2_out);
35 ck_assert(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);
189 static const char characters[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
190 static void random_string(
char *buffer,
int length){
192 for (
i=0;
i<length;
i++){
193 buffer[
i] = characters[rand() % (
sizeof(characters)-1)];
199 int i,
j, contains_dupes,
count = 1000, length = 8;
200 char keys[
count][length+1];
204 random_string(keys[
i], length);
205 random_string(
values[
i], length);
206 keys[
i][length] =
'\0';
213 if (!strcmp(keys[
i], keys[
j])){
215 random_string(keys[
j], length);
219 }
while (contains_dupes);
233 char *test_key = malloc(strlen(
"key1") + 1);
234 strncpy(test_key,
"key1", strlen(
"key1") + 1);
237 ck_assert_int_eq(
phash_set(p2, test_key,
"testval"), 0);
239 ck_assert_str_eq(
phash_get(p2,
"key1"),
"testval");
245 Suite *
s = suite_create(
"Stub");
247 TCase *tc_core = tcase_create(
"Core");
248 tcase_add_test(tc_core, set_1);
249 tcase_add_test(tc_core, remove_1);
250 tcase_add_test(tc_core, iterating);
251 tcase_add_test(tc_core, iterating_one_value);
252 tcase_add_test(tc_core, stress_test);
253 tcase_add_test(tc_core, copy_keys);
254 suite_add_tcase(
s, tc_core);
256 TCase *tc_segfaults = tcase_create(
"Segfaults");
257 tcase_add_test(tc_segfaults, set_1);
258 tcase_add_test(tc_segfaults, get_out_of_scope);
259 tcase_add_test(tc_segfaults, set_out_of_scope);
260 suite_add_tcase(
s, tc_segfaults);
265 int main(
int argc,
char **argv){
269 SRunner *sr = srunner_create(
s);
271 srunner_run_all(sr, CK_VERBOSE);
272 number_failed = srunner_ntests_failed(sr);
274 return (number_failed == 0) ?
EXIT_SUCCESS : EXIT_FAILURE;
int main(int argc, char **argv)
#define PHASH_NO_COPY_KEYS
A simple dictionary library for storing pointers.
phash * phash_create(uint32_t options)
Initialize a phash object.
int phash_remove(phash *h, const char *key)
Remove a pointer associated with the given string.
Implementation-specific, generic type to store the phash object.
int phash_set(phash *h, const char *key, void *value)
Add or overwrite a pointer, associating it with the given key.
END_TEST Suite * stub_suite(void)
void * phash_get(phash *h, const char *key)
Find a pointer associated with the given string.
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
PARAM_TYPE_NONE Default value No parameter is buried in the product name name_prefix is case insensitive string compared to the product name PARAM_TYPE_VIS_WAVE The visible wavelength bands from the sensor are buried in the product name The product name is compared by appending and name_suffix ie aph_412_giop where prod_ix will be set to PARAM_TYPE_IR_WAVE same search method as PARAM_TYPE_VIS_WAVE except only wavelength above are looped through but prod_ix is still based ie aph_2_giop for the second and prod_ix set to PARAM_TYPE_INT name_prefix is compared with the beginning of the product name If name_suffix is not empty the it must match the end of the product name The characters right after the prefix are read as an integer and prod_ix is set to that number strncpy(l2prod->name_prefix, "myprod", UNITLEN)
int phash_next(phash *h, const char **key, void **value)
Retrieves the next key-value pair in the phash. The order in which the pointers are returned shall be...
int phash_destroy(phash *h)
Destroy a phash object, free'ing the memory used.
int phash_rewind(phash *h)
Rewind iterator for traversing all the keys and values.