Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 05e4540

Browse files
committed
Switch to the Clay testing framework
1 parent c035ede commit 05e4540

37 files changed

+1106
-8007
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ IF (BUILD_TESTS)
119119
ADD_DEFINITIONS(-DTEST_RESOURCES=\"${TEST_RESOURCES}\")
120120

121121
INCLUDE_DIRECTORIES(tests)
122-
FILE(GLOB SRC_TEST tests/t??-*.c)
122+
FILE(GLOB SRC_TEST tests/*.c)
123123

124-
ADD_EXECUTABLE(libgit2_test tests/test_main.c tests/test_lib.c tests/test_helpers.c ${SRC} ${SRC_TEST} ${SRC_ZLIB})
124+
ADD_EXECUTABLE(libgit2_test ${SRC} ${SRC_TEST} ${SRC_ZLIB})
125125
TARGET_LINK_LIBRARIES(libgit2_test ${CMAKE_THREAD_LIBS_INIT})
126126
IF (WIN32)
127127
TARGET_LINK_LIBRARIES(libgit2_test ws2_32)

tests/NAMING

Lines changed: 0 additions & 52 deletions
This file was deleted.

tests/clay.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#ifndef __CLAY_TEST_H__
2+
#define __CLAY_TEST_H__
3+
4+
#include <stdlib.h>
5+
6+
void clay__assert(
7+
int condition,
8+
const char *file,
9+
int line,
10+
const char *error,
11+
const char *description,
12+
int should_abort);
13+
14+
void clay_set_cleanup(void (*cleanup)(void *), void *opaque);
15+
16+
#define clay_must_pass(expr, desc) clay__assert((expr) >= 0, __FILE__, __LINE__, "Function call failed: " #expr, desc, 1)
17+
#define clay_must_fail(expr, desc) clay__assert((expr) < 0, __FILE__, __LINE__, "Expected function call to fail: " #expr, desc, 1)
18+
#define clay_assert(expr, desc) clay__assert((expr) != 0, __FILE__, __LINE__, "Expression is not true: " #expr, desc, 1)
19+
20+
#define clay_check_pass(expr, desc) clay__assert((expr) >= 0, __FILE__, __LINE__, "Function call failed: " #expr, desc, 0)
21+
#define clay_check_fail(expr, desc) clay__assert((expr) < 0, __FILE__, __LINE__, "Expected function call to fail: " #expr, desc, 0)
22+
#define clay_check(expr, desc) clay__assert((expr) != 0, __FILE__, __LINE__, "Expression is not true: " #expr, desc, 0)
23+
24+
#define clay_fail(desc) clay__assert(0, __FILE__, __LINE__, "Test failed.", desc, 1)
25+
#define clay_warning(desc) clay__assert(0, __FILE__, __LINE__, "Warning during test execution:", desc, 0)
26+
27+
#endif

tests/clay_libgit2.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#ifndef __CLAY_LIBGIT2__
2+
#define __CLAY_LIBGIT2__
3+
4+
#include "clay.h"
5+
#include <git2.h>
6+
#include "common.h"
7+
8+
#define must_be_true(expr) clay_assert(expr, NULL)
9+
#define must_pass(expr) clay_must_pass(expr, NULL)
10+
#define must_fail(expr) clay_must_fail(expr, NULL)
11+
12+
#endif

0 commit comments

Comments
 (0)