Skip to content
Permalink
Browse files

Hook tweak

  • Loading branch information...
PJK committed Feb 2, 2019
1 parent 2083114 commit ade51a28fd0c25f20f3cbb0090ff4c86a99e0af4
Showing with 18 additions and 17 deletions.
  1. +3 −0 misc/hooks/pre-commit
  2. +15 −17 test/memory_allocation_test.c
@@ -15,9 +15,12 @@ cd ..

# Run clang-format and add modified files
MODIFIED_UNSTAGED=$(git -C . diff --name-only)
MODIFIED_STAGED=$(git -C . diff --name-only --cached)

./clang-format.sh

git add ${MODIFIED_STAGED}

if [[ ${MODIFIED_UNSTAGED} != $(git -C . diff --name-only) ]]; then
echo "WARNING: Non-staged files were reformatted. Please review and/or add" \
"them"
@@ -237,23 +237,21 @@ static void test_array_push(void **state) {

static void test_map_add(void **state) {
WITH_MOCK_MALLOC(
{
cbor_item_t *map = cbor_new_indefinite_map();
cbor_item_t *key = cbor_build_uint8(0);
cbor_item_t *value = cbor_build_bool(true);

assert_false(cbor_map_add(map, (struct cbor_pair) {
.key = key,
.value = value
}));
assert_int_equal(cbor_map_allocated(map), 0);
assert_null(map->data);

cbor_decref(&map);
cbor_decref(&key);
cbor_decref(&value);
},
4, MALLOC, MALLOC, MALLOC, REALLOC_FAIL);
{
cbor_item_t *map = cbor_new_indefinite_map();
cbor_item_t *key = cbor_build_uint8(0);
cbor_item_t *value = cbor_build_bool(true);

assert_false(
cbor_map_add(map, (struct cbor_pair){.key = key, .value = value}));
assert_int_equal(cbor_map_allocated(map), 0);
assert_null(map->data);

cbor_decref(&map);
cbor_decref(&key);
cbor_decref(&value);
},
4, MALLOC, MALLOC, MALLOC, REALLOC_FAIL);
}

int main(void) {

0 comments on commit ade51a2

Please sign in to comment.
You can’t perform that action at this time.