-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* set test-related makefile templates with more proper name * added checkmk tests * described checkmk in Demo * update gcovr string
- Loading branch information
Showing
8 changed files
with
212 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
*.test.cpp | ||
*.dummy.cpp | ||
*_test | ||
*_checkmk | ||
*_checkmk.* | ||
_meta_* | ||
metac | ||
coverage_*.css | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,7 @@ | |
"iterator.h": "c", | ||
"reqresp.h": "c", | ||
"complex.h": "c", | ||
"stdint.h": "c" | ||
"stdint.h": "c", | ||
"test.h": "c" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "demodb.h" | ||
|
||
# suite Demo Suite | ||
# tcase Demo Test Case | ||
# test append_test | ||
struct { | ||
person_t * p_in; | ||
int expected_err; | ||
}tcs[] = { | ||
{ | ||
.p_in = NULL, | ||
.expected_err = 1, | ||
}, | ||
{ | ||
.p_in = (person_t[]){{ | ||
.firstname="Joe", | ||
.lastname="Doe", | ||
.age = 43, | ||
.marital_status = msMarried, | ||
}}, | ||
.expected_err = 0, | ||
}, | ||
{ | ||
.p_in = (person_t[]){{ | ||
.firstname="Jane", | ||
.lastname="Doe", | ||
.age = 34, | ||
.marital_status = msMarried, | ||
}}, | ||
.expected_err = 0, | ||
}, | ||
{ | ||
.p_in = (person_t[]){{ | ||
.firstname="Jack", | ||
.lastname="Doe", | ||
.age = 3, | ||
.marital_status = msSingle, | ||
}}, | ||
.expected_err = 0, | ||
}, | ||
}; | ||
db_t * p_db = new_db(); | ||
for (int tc_inx = 0; tc_inx < sizeof(tcs)/sizeof(tcs[0]); tc_inx++) { | ||
int res = db_append(&p_db, tcs[tc_inx].p_in); | ||
fail_unless((res != 0) == (tcs[tc_inx].expected_err != 0), "unexpected err result %i, expected %i", res, tcs[tc_inx].expected_err); | ||
} | ||
db_delete(p_db); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
#include "entry.c" | ||
#include "iterator.c" | ||
#include "value.c" | ||
#include "value_base_type.c" | ||
|
||
enum t1 { | ||
t1_a = 0, | ||
t1_b = 1, | ||
t1_z = -1, | ||
t1_c, | ||
t1_d, | ||
}test1 = t1_c; | ||
METAC_GSYM_LINK(test1); | ||
|
||
struct { | ||
enum t1 t2_fld; | ||
}test2 = {.t2_fld = t1_c}; | ||
METAC_GSYM_LINK(test2); | ||
|
||
# suite A Suite 1 | ||
# tcase A Test Case 1 | ||
# test test1_sanity | ||
metac_value_t * p_val = METAC_VALUE_FROM_LINK(test1); | ||
|
||
metac_num_t sz = metac_value_enumeration_info_size(p_val); | ||
fail_unless(sz == 5, "expected 5 possible values, got %d", (int)sz); | ||
|
||
struct metac_type_enumerator_info const * p_i = metac_value_enumeration_info(p_val, 2); | ||
fail_unless(p_i != NULL, "got NULL istead of info"); | ||
fail_unless(strcmp(p_i->name, "t1_z") == 0, "expect t1_z on the 2nd place, got %s", p_i->name); | ||
fail_unless(p_i->const_value == t1_z, "expected values to be equal t1_z"); | ||
|
||
metac_name_t n = metac_value_enumeration_to_name(p_val, -1); | ||
fail_unless(n != NULL, "expected -1(t1_z) is in rage"); | ||
fail_unless(strcmp(n, "t1_z") == 0 , "expected 't1_z' for -1"); | ||
fail_unless(metac_value_enumeration_to_name(p_val, -2) == NULL, "expected -2 isn't in rage"); | ||
|
||
metac_const_value_t var; | ||
fail_unless(metac_value_enumeration(p_val, &var) == 0, "couldn't read enum"); | ||
fail_unless(var == test1, "expected var to be equal t1_c"); | ||
|
||
var = t1_z; | ||
fail_unless(metac_value_set_enumeration(p_val, var) == 0, "couldn't write enum"); | ||
fail_unless(var == test1, "expected var to be equal t1_z"); | ||
|
||
var = -2; | ||
fail_unless(metac_value_set_enumeration(p_val, var) == 0, "couldn't write enum"); | ||
fail_unless(var == test1, "expected var to be equal -2 (though it's not in range of enum)"); | ||
|
||
metac_value_delete(p_val); | ||
|
||
# suite A Suite 2 | ||
# tcase A Test Case 2 | ||
# test test2_sanity | ||
metac_value_t * p_sval = METAC_VALUE_FROM_LINK(test2); | ||
fail_unless(metac_value_has_members(p_sval) == 1, "must be entity with members"); | ||
metac_num_t nm = metac_value_member_count(p_sval); | ||
fail_unless(nm == 1, "expected 1 memeber, got %d", (int)nm); | ||
|
||
metac_value_t * p_val = metac_new_value_by_member_id(p_sval, 0); | ||
fail_unless(p_val != NULL, "expected 1st memeber non NULL"); | ||
|
||
metac_num_t sz = metac_value_enumeration_info_size(p_val); | ||
fail_unless(sz == 5, "expected 5 possible values, got %d", (int)sz); | ||
|
||
struct metac_type_enumerator_info const * p_i = metac_value_enumeration_info(p_val, 2); | ||
fail_unless(p_i != NULL, "got NULL istead of info"); | ||
fail_unless(strcmp(p_i->name, "t1_z") == 0, "expect t1_z on the 2nd place, got %s", p_i->name); | ||
fail_unless(p_i->const_value == t1_z, "expected values to be equal t1_z"); | ||
|
||
metac_name_t n = metac_value_enumeration_to_name(p_val, -1); | ||
fail_unless(n != NULL, "expected -1(t1_z) is in rage"); | ||
fail_unless(strcmp(n, "t1_z") == 0 , "expected 't1_z' for -1"); | ||
fail_unless(metac_value_enumeration_to_name(p_val, -2) == NULL, "expected -2 isn't in rage"); | ||
|
||
|
||
metac_const_value_t var; | ||
fail_unless(metac_value_enumeration(p_val, &var) == 0, "couldn't read enum"); | ||
fail_unless(var == test2.t2_fld, "expected var to be equal t1_c"); | ||
|
||
var = t1_z; | ||
fail_unless(metac_value_set_enumeration(p_val, var) == 0, "couldn't write enum"); | ||
fail_unless(var == test2.t2_fld, "expected var to be equal t1_z"); | ||
|
||
var = -2; | ||
fail_unless(metac_value_set_enumeration(p_val, var) == 0, "couldn't write enum"); | ||
fail_unless(var == test2.t2_fld, "expected var to be equal -2 (though it's not in range of enum)"); | ||
|
||
metac_value_delete(p_val); | ||
metac_value_delete(p_sval); |