Compare commits
2 Commits
219812f20e
...
c186195e24
| Author | SHA1 | Date | |
|---|---|---|---|
| c186195e24 | |||
| 0cfc4c72ca |
10
.drone.yml
10
.drone.yml
@ -38,7 +38,7 @@ name: tag
|
||||
|
||||
steps:
|
||||
- name: Build release
|
||||
image: registry.riba-interactive.de/alpine-build:3
|
||||
image: registry.riba-interactive.de/alpine-build:4
|
||||
commands:
|
||||
- cmake -S. -Bcmake-build-ci -DCMAKE_BUILD_TYPE=Release
|
||||
- cd cmake-build-ci
|
||||
@ -58,12 +58,18 @@ name: Build and Test
|
||||
|
||||
steps:
|
||||
- name: Build and run tests
|
||||
image: registry.riba-interactive.de/alpine-build:3
|
||||
image: registry.riba-interactive.de/alpine-build:4
|
||||
commands:
|
||||
- cmake -S. -Bcmake-build-ci -DCMAKE_BUILD_TYPE=Debug -DENABLE_TEST_COVERAGE=on
|
||||
- cd cmake-build-ci
|
||||
- cmake --build .
|
||||
- make coverage
|
||||
- name: Generate memory report
|
||||
image: registry.riba-interactive.de/reportly:latest
|
||||
settings:
|
||||
input_path: Testing
|
||||
report_output: reports/memory_report.md
|
||||
verbose: true
|
||||
|
||||
- name: Report test and coverage
|
||||
image: alpine
|
||||
|
||||
@ -33,9 +33,11 @@ if ((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR MODERN_CMAKE_BUILD_TESTING)
|
||||
if (ENABLE_TEST_COVERAGE)
|
||||
include(CodeCoverage)
|
||||
|
||||
set(MEMORYCHECK_COMMAND_OPTIONS "--trace-children=yes --leak-check=full")
|
||||
|
||||
setup_target_for_coverage_lcov(
|
||||
NAME coverage
|
||||
EXECUTABLE ${CMAKE_CTEST_COMMAND}
|
||||
EXECUTABLE ${CMAKE_CTEST_COMMAND} -T memcheck
|
||||
EXCLUDE "tests/*"
|
||||
LCOV_ARGS --rc lcov_branch_coverage=1
|
||||
GENHTML_ARGS --rc genhtml_branch_coverage=1
|
||||
|
||||
@ -8,4 +8,5 @@ RUN echo "@testing https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/a
|
||||
flex \
|
||||
git \
|
||||
ncurses-dev\
|
||||
lcov@testing
|
||||
lcov@testing \
|
||||
valgrind
|
||||
@ -109,12 +109,22 @@ spec("hashtable") {
|
||||
|
||||
it("should not work with the str having NULL as string") {
|
||||
str key = STR_NULL_INIT;
|
||||
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 0);
|
||||
value *value = value_new(1337);
|
||||
check(value_hashtable_insert(hashtable, key, value) == 0);
|
||||
check(value != NULL, "value should not be NULL");
|
||||
//value_destroy(&value);
|
||||
free(value);
|
||||
free(value);
|
||||
value_new(1234);
|
||||
free(NULL);
|
||||
}
|
||||
|
||||
it("should return 0 with NULL as this param") {
|
||||
str key = STR_STATIC_INIT("leet");
|
||||
check(value_hashtable_insert(NULL, key, value_new(1)) == 0, "return should be 0");
|
||||
value *value = value_new(1);
|
||||
check(value_hashtable_insert(NULL, key, value) == 0, "return should be 0");
|
||||
check(value != NULL, "value should not be NULL");
|
||||
value_destroy(&value);
|
||||
}
|
||||
|
||||
it("should not allow double entry") {
|
||||
@ -124,7 +134,10 @@ spec("hashtable") {
|
||||
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 1);
|
||||
check(value_hashtable_has(hashtable, key) == 1, "hashtable should have the key");
|
||||
|
||||
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 0);
|
||||
value *value = value_new(1337);
|
||||
check(value_hashtable_insert(hashtable, key, value) == 0, "return should be 0");
|
||||
check(value != NULL, "value should not be NULL");
|
||||
value_destroy(&value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +180,6 @@ spec("hashtable") {
|
||||
check(value_hashtable_markStolenCheck(hashtable, key, (value_hashtable_value_check_fn) value_check_counter, &counter) == 1);
|
||||
check(value_hashtable_isStolenCheck(hashtable, key, (value_hashtable_value_check_fn) value_check_counter, &counter) == 1);
|
||||
value_destroy(&resultValue);
|
||||
check(resultValue == NULL, "resultValue should be NULL");
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,12 +218,15 @@ spec("hashtable") {
|
||||
describe("value_hashtable_markStolen()") {
|
||||
it("should mark the value for the given key as stolen") {
|
||||
str key = STR_STATIC_INIT("leet");
|
||||
|
||||
value *value = NULL;
|
||||
check(value_hashtable_has(hashtable, key) == 0,"hashtable should not have the key already");
|
||||
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 1);
|
||||
check(value_hashtable_has(hashtable, key) == 1, "hashtable should have the key");
|
||||
value = value_hashtable_lookup(hashtable, key);
|
||||
check(value != NULL, "value should not be NULL");
|
||||
check(value_hashtable_markStolen(hashtable, key) == 1, "hashtable should mark the value for the key as stolen");
|
||||
check(value_hashtable_isStolen(hashtable, key) == 1, "hashtable should have the value for the key marked as stolen");
|
||||
value_destroy(&value);
|
||||
}
|
||||
|
||||
it("should return 0 the given key that is not existing") {
|
||||
@ -224,8 +239,12 @@ spec("hashtable") {
|
||||
|
||||
it("should work with the empty str") {
|
||||
str key = STR_STATIC_INIT("");
|
||||
value *value = NULL;
|
||||
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 1);
|
||||
value = value_hashtable_lookup(hashtable, key);
|
||||
check(value != NULL, "value should not be NULL");
|
||||
check(value_hashtable_markStolen(hashtable, key) == 1, "return should be 1");
|
||||
value_destroy(&value);
|
||||
}
|
||||
|
||||
it("should not work with the str having NULL as string") {
|
||||
@ -303,6 +322,7 @@ spec("hashtable") {
|
||||
str otherKey2 = STR_STATIC_INIT("otherKey2");
|
||||
str otherKey3 = STR_STATIC_INIT("otherKey3");
|
||||
str otherKey4 = STR_STATIC_INIT("otherKey4");
|
||||
value *value = NULL;
|
||||
|
||||
check(value_hashtable_has(hashtable, key) == 0,"hashtable should not have the key already");
|
||||
check(value_hashtable_insert(hashtable, key, value_new(1337)) == 1);
|
||||
@ -313,8 +333,11 @@ spec("hashtable") {
|
||||
check(value_hashtable_insert(hashtable, otherKey3, value_new(1337)) == 1);
|
||||
check(value_hashtable_insert(hashtable, otherKey4, value_new(1337)) == 1);
|
||||
|
||||
value = value_hashtable_lookup(hashtable, key);
|
||||
check(value != NULL, "value should not be NULL");
|
||||
check(value_hashtable_markStolen(hashtable, key) == 1, "hashtable should mark the value for the key as stolen");
|
||||
check(value_hashtable_isStolen(hashtable, key) == 1, "hashtable should have the value for the key marked as stolen");
|
||||
value_destroy(&value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +78,10 @@ spec("list") {
|
||||
for_it_end();
|
||||
|
||||
it("should return 0 with NULL as this param") {
|
||||
check(value_list_push(NULL, value_new(1)) == 0, "return should not be 0");
|
||||
value *value = value_new(1);
|
||||
check(value_list_push(NULL, value) == 0, "return should not be 0");
|
||||
check(value != NULL, "value should not be NULL");
|
||||
value_destroy(&value);
|
||||
}
|
||||
|
||||
it("should return 0 with NULL as valueElement param") {
|
||||
@ -130,7 +133,9 @@ spec("list") {
|
||||
for_it_end();
|
||||
|
||||
it("should return 0 with NULL as this param") {
|
||||
check(value_list_unshift(NULL, value_new(1)) == 0, "return should not be 0");
|
||||
value *value = value_new(1);
|
||||
check(value_list_unshift(NULL, value) == 0, "return should not be 0");
|
||||
//value_destroy(&value);
|
||||
}
|
||||
|
||||
it("should return 0 with NULL as valueElement param") {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user