Compare commits
9 Commits
dbd7f58025
...
main
Author | SHA1 | Date | |
---|---|---|---|
f4a359b871
|
|||
ba65e6c433
|
|||
f3ca4cdd72
|
|||
84ba41e180
|
|||
1aba159f8f
|
|||
1401e1d70b
|
|||
3f5cbdd276
|
|||
5c08d33f22
|
|||
ed41c04209 |
41
Makefile
41
Makefile
@@ -1,41 +0,0 @@
|
|||||||
ifndef verbose
|
|
||||||
SILENT = @
|
|
||||||
endif
|
|
||||||
|
|
||||||
CC := gcc
|
|
||||||
AR := ar
|
|
||||||
CFLAGS := -I include/
|
|
||||||
|
|
||||||
ifeq ($(colorized), y)
|
|
||||||
CFLAGS += -D COLORIZED
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(no_banner), y)
|
|
||||||
CFLAGS += -D NO_BANNER
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(testing), y)
|
|
||||||
CFLAGS += -g2 -O0
|
|
||||||
else
|
|
||||||
CFLAGS += -O2
|
|
||||||
endif
|
|
||||||
|
|
||||||
all: create_output_dir libset.a
|
|
||||||
|
|
||||||
clean:
|
|
||||||
$(SILENT) rm -rf int/
|
|
||||||
$(SILENT) rm -f libset.a
|
|
||||||
|
|
||||||
create_output_dir:
|
|
||||||
$(SILENT) mkdir -p int/
|
|
||||||
|
|
||||||
libset.a: $(patsubst src/%.c, int/%.o, $(wildcard src/*.c))
|
|
||||||
@echo "Archiving $^ to $@"
|
|
||||||
$(SILENT) $(AR) rcs $@ int/**.o
|
|
||||||
|
|
||||||
# Recipe
|
|
||||||
int/%.o: src/%.c
|
|
||||||
@echo "Building $< => $@"
|
|
||||||
$(SILENT) $(CC) $(CFLAGS) -c $< -o $@
|
|
||||||
|
|
||||||
.PHONY: all clean test create_output_dir
|
|
24
README.md
24
README.md
@@ -2,33 +2,11 @@
|
|||||||
|
|
||||||
Tiny C testing framework.
|
Tiny C testing framework.
|
||||||
|
|
||||||
## Build
|
|
||||||
|
|
||||||
To build the library simply call `make` in the repository root.
|
|
||||||
|
|
||||||
Alternatively it is possible to directly call the compiler with:
|
|
||||||
|
|
||||||
gcc -c src/*.c
|
|
||||||
ar rcs libset.a *.o
|
|
||||||
rm *.o # Clean up
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
SET comes with a couple of build options that might come in handy in different scenarios.
|
|
||||||
|
|
||||||
- no_banner: Do not print banner every time the tests are run.
|
|
||||||
|
|
||||||
make no_banner=y
|
|
||||||
|
|
||||||
- colorized: Build with colorized output.
|
|
||||||
|
|
||||||
make colorized=y
|
|
||||||
|
|
||||||
## Building a test.
|
## Building a test.
|
||||||
|
|
||||||
To build a test, first build the library. Then link it to the `test.c` via:
|
To build a test, first build the library. Then link it to the `test.c` via:
|
||||||
|
|
||||||
gcc -static test.c -L . -lset -o test
|
gcc src/*.c test.c -o test
|
||||||
|
|
||||||
## LICENSE
|
## LICENSE
|
||||||
|
|
||||||
|
@@ -1,3 +1,6 @@
|
|||||||
|
#ifndef INCLUDE_SET_LIST_
|
||||||
|
#define INCLUDE_SET_LIST_
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
struct SETBlockMeta
|
struct SETBlockMeta
|
||||||
@@ -31,3 +34,5 @@ void set_ll_free_all(struct SETBlockMeta *head);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
struct SETBlockMeta *set_ll_free_one(struct SETBlockMeta *head, void *address);
|
struct SETBlockMeta *set_ll_free_one(struct SETBlockMeta *head, void *address);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
139
include/set.h
139
include/set.h
@@ -1,79 +1,88 @@
|
|||||||
|
#ifndef __cplusplus
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/shm.h>
|
#include <sys/shm.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#include <cstdio>
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#ifndef INCLUDE_SET_H
|
#ifndef INCLUDE_SET_H
|
||||||
#define INCLUDE_SET_H
|
#define INCLUDE_SET_H
|
||||||
|
|
||||||
#define SET_MAX_ERROR_MSG_SIZE 256
|
/**
|
||||||
#define SET_MAX_NAME_SIZE 64
|
* Meta data for one test function.
|
||||||
|
*
|
||||||
|
* See also: struct SETSuit
|
||||||
|
*/
|
||||||
|
struct SETest
|
||||||
|
{
|
||||||
|
void (*function)(struct SETest *test);
|
||||||
|
const char *error_msg;
|
||||||
|
const char *name;
|
||||||
|
bool passed;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meta data for one test function.
|
* Meta data for one test suit.
|
||||||
*
|
*
|
||||||
* See also: struct SETSuit
|
* See also: struct SETest
|
||||||
*/
|
*/
|
||||||
struct SETest
|
struct SETSuit
|
||||||
{
|
{
|
||||||
void (*function)(struct SETest *test);
|
const char *name;
|
||||||
const char *error_msg;
|
struct SETest *tests;
|
||||||
const char *name;
|
int len;
|
||||||
bool passed;
|
int shm_key;
|
||||||
};
|
bool (*setup)();
|
||||||
|
bool (*tear_down)();
|
||||||
|
bool passed;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Meta data for one test suit.
|
* Internal function header for bundle. Use BUNDLE() macro to define bundle
|
||||||
*
|
* in test.
|
||||||
* See also: struct SETest
|
*/
|
||||||
*/
|
void set_bundle_suits(struct SETSuit **suits, int *counter, bool count);
|
||||||
struct SETSuit
|
|
||||||
{
|
|
||||||
const char *name;
|
|
||||||
struct SETest *tests;
|
|
||||||
int len;
|
|
||||||
int shm_key;
|
|
||||||
bool (*setup)();
|
|
||||||
bool (*tear_down)();
|
|
||||||
bool passed;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal function header for bundle. Use BUNDLE() macro to define bundle in
|
* Empty suit_setup. Resolving EMPTY in a suit constructor gets
|
||||||
* test.
|
* us here.
|
||||||
*/
|
*
|
||||||
void set_bundle_suits(struct SETSuit **suits, int *counter, bool count);
|
* Note: Use EMPTY instead of this function.
|
||||||
|
*/
|
||||||
|
static bool EMPTY_suit_setup() { return true; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty suit_setup. Resolving EMPTY in a suit constructor gets
|
* Empty suit_tear_down. Resolving EMPTY in a suit constructor gets
|
||||||
* us here.
|
* us here.
|
||||||
*
|
*
|
||||||
* Note: Use EMPTY instead of this function.
|
* Note: Use EMPTY instead of this function.
|
||||||
*/
|
*/
|
||||||
static bool EMPTY_suit_setup() { return true; }
|
static bool EMPTY_suit_tear_down() { return true; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty suit_tear_down. Resolving EMPTY in a suit constructor gets
|
* Internal header for global setup. Use SETUP() macro instead.
|
||||||
* us here.
|
*/
|
||||||
*
|
bool set_up();
|
||||||
* Note: Use EMPTY instead of this function.
|
|
||||||
*/
|
|
||||||
static bool EMPTY_suit_tear_down() { return true; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal header for global setup. Use SETUP() macro instead.
|
* Internal header for global tear down. Use TEAR_DOWN() macro instead.
|
||||||
*/
|
*/
|
||||||
bool set_up();
|
bool tear_down();
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal header for global tear down. Use TEAR_DOWN() macro instead.
|
|
||||||
*/
|
|
||||||
bool tear_down();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global setup function.
|
* Global setup function.
|
||||||
@@ -160,17 +169,17 @@ bool tear_down();
|
|||||||
void suit_name##_suit(struct SETSuit *suit, bool count); \
|
void suit_name##_suit(struct SETSuit *suit, bool count); \
|
||||||
struct SETSuit *suit_name##_suit_contructor() \
|
struct SETSuit *suit_name##_suit_contructor() \
|
||||||
{ \
|
{ \
|
||||||
struct SETSuit *suit = \
|
struct SETSuit *suit = (struct SETSuit *)mmap( \
|
||||||
mmap(NULL, sizeof(struct SETSuit), PROT_READ | PROT_WRITE, \
|
NULL, sizeof(struct SETSuit), PROT_READ | PROT_WRITE, \
|
||||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
|
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); \
|
||||||
madvise(suit, sizeof(struct SETSuit), MADV_DONTFORK); \
|
madvise(suit, sizeof(struct SETSuit), MADV_DONTFORK); \
|
||||||
suit->len = 0; \
|
suit->len = 0; \
|
||||||
suit_name##_suit(suit, true); \
|
suit_name##_suit(suit, true); \
|
||||||
suit->shm_key = \
|
suit->shm_key = \
|
||||||
create_shared_suit_space(suit->len * sizeof(struct SETest)); \
|
create_shared_suit_space(suit->len * sizeof(struct SETest)); \
|
||||||
suit->name = #suit_name; \
|
suit->name = #suit_name; \
|
||||||
suit->tests = shmat(suit->shm_key, 0, 0); \
|
suit->tests = (struct SETest *)shmat(suit->shm_key, 0, 0); \
|
||||||
if (suit->tests == (struct SETest *)-1) \
|
if ((uint64_t)suit->tests == -1) \
|
||||||
{ \
|
{ \
|
||||||
fprintf(stderr, "Couldn't attach suit space.\n"); \
|
fprintf(stderr, "Couldn't attach suit space.\n"); \
|
||||||
perror("shmat"); \
|
perror("shmat"); \
|
||||||
@@ -242,3 +251,7 @@ bool tear_down();
|
|||||||
void test_name##_test(struct SETest *test)
|
void test_name##_test(struct SETest *test)
|
||||||
|
|
||||||
#endif // !INCLUDE_SET_H
|
#endif // !INCLUDE_SET_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
#include "set.h"
|
#include "set.h"
|
||||||
|
|
||||||
#ifndef ASSERT_H
|
#ifndef INCLUDE_SET_ASSERT_H
|
||||||
#define ASSERT_H
|
#define INCLUDE_SET_ASSERT_H
|
||||||
|
|
||||||
#define STATIC_ASSERT(condition) (void)sizeof(char[1 - 2 * (!(condition))])
|
#define STATIC_ASSERT(condition) (void)sizeof(char[1 - 2 * (!(condition))])
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
{ \
|
{ \
|
||||||
test->passed = false; \
|
test->passed = false; \
|
||||||
test->error_msg = \
|
test->error_msg = \
|
||||||
format_string("Expect %d to be %d.\n", act, exp) return; \
|
format_string("Expect %d not to be %d.\n", act, exp) return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ASSERT_EQ_MSG(exp, act, msg) \
|
#define ASSERT_EQ_MSG(exp, act, msg) \
|
||||||
@@ -33,6 +33,16 @@
|
|||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ASSERT_NEQ_MSG(exp, act, msg) \
|
||||||
|
if (exp == act) \
|
||||||
|
{ \
|
||||||
|
test->passed = false; \
|
||||||
|
test->error_msg = format_string( \
|
||||||
|
"Expected %d not to be %d\n Failed with message: " msg, act, \
|
||||||
|
exp); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
#define ASSERT_TRUE(x) \
|
#define ASSERT_TRUE(x) \
|
||||||
if (!x) \
|
if (!x) \
|
||||||
{ \
|
{ \
|
||||||
@@ -41,6 +51,15 @@
|
|||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ASSERT_TRUE_MSG(x, msg) \
|
||||||
|
if (!x) \
|
||||||
|
{ \
|
||||||
|
test->passed = false; \
|
||||||
|
test->error_msg = format_string( \
|
||||||
|
"Expected true got false.\n Failed with message: " msg); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
#define ASSERT_FALSE(x) \
|
#define ASSERT_FALSE(x) \
|
||||||
if (x) \
|
if (x) \
|
||||||
{ \
|
{ \
|
||||||
@@ -49,6 +68,15 @@
|
|||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ASSERT_FALSE_MSG(x, msg) \
|
||||||
|
if (x) \
|
||||||
|
{ \
|
||||||
|
test->passed = false; \
|
||||||
|
test->error_msg = format_string( \
|
||||||
|
"Expected false got true.\n Failed with message: " msg); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
#define ASSERT_EQ_FLOAT(exp, act, epsilon) \
|
#define ASSERT_EQ_FLOAT(exp, act, epsilon) \
|
||||||
if (fabs(exp - act) <= epsilon) \
|
if (fabs(exp - act) <= epsilon) \
|
||||||
{ \
|
{ \
|
||||||
@@ -58,12 +86,32 @@
|
|||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ASSERT_EQ_FLOAT_MSG(exp, act, epsilon, msg) \
|
||||||
|
if (fabs(exp - act) <= epsilon) \
|
||||||
|
{ \
|
||||||
|
test->passed = false; \
|
||||||
|
test->error_msg = format_string( \
|
||||||
|
"Expected %f to be %f (e: %f)\n Failed with message: " msg, \
|
||||||
|
act, exp, epsilon); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
#define ASSERT_NEQ_FLOAT(exp, act, epsilon) \
|
#define ASSERT_NEQ_FLOAT(exp, act, epsilon) \
|
||||||
if (fabs(exp - act) > epsilon) \
|
if (fabs(exp - act) > epsilon) \
|
||||||
{ \
|
{ \
|
||||||
test->passed = false; \
|
test->passed = false; \
|
||||||
test->error_msg = \
|
test->error_msg = format_string("Expected %f not to be %f (e: %f)", \
|
||||||
format_string("Expected %f to be %f (e: %f)", act, exp, epsilon); \
|
act, exp, epsilon); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ASSERT_NEQ_FLOAT_MSG(exp, act, epsilon, msg) \
|
||||||
|
if (fabs(exp - act) > epsilon) \
|
||||||
|
{ \
|
||||||
|
test->passed = false; \
|
||||||
|
test->error_msg = format_string( \
|
||||||
|
"Expected %f not to be %f (e: %f)\n Failed with message: " msg, \
|
||||||
|
act, exp, epsilon); \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,12 +124,32 @@
|
|||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ASSERT_EQ_STR_MSG(exp, act, msg) \
|
||||||
|
if (strcmp(exp, act) != 0) \
|
||||||
|
{ \
|
||||||
|
test->passed = false; \
|
||||||
|
type->error_msg = format_string( \
|
||||||
|
"Expected: %d\nBut got: %d\n Failed with message: " msg, act, \
|
||||||
|
exp); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
#define ASSERT_NEQ_STR(exp, act) \
|
#define ASSERT_NEQ_STR(exp, act) \
|
||||||
if (strcmp(exp, act) == 0) \
|
if (strcmp(exp, act) == 0) \
|
||||||
{ \
|
{ \
|
||||||
test->passed = false; \
|
test->passed = false; \
|
||||||
type->error_msg = \
|
type->error_msg = \
|
||||||
format_string("Expected: %d\nBut got: %d", act, exp); \
|
format_string("Expected not: %d\nBut got: %d", act, exp); \
|
||||||
|
return; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define ASSERT_NEQ_STR_MSG(exp, act, msg) \
|
||||||
|
if (strcmp(exp, act) == 0) \
|
||||||
|
{ \
|
||||||
|
test->passed = false; \
|
||||||
|
type->error_msg = format_string( \
|
||||||
|
"Expected not: %d\nBut got: %d\n Failed with message: " msg, \
|
||||||
|
act, exp); \
|
||||||
return; \
|
return; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,8 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
#ifndef INCLUDE_SET_UTILS_H_
|
||||||
|
#define INCLUDE_SET_UTILS_H_
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns pointer to formatted the string.
|
* Returns pointer to formatted the string.
|
||||||
*
|
*
|
||||||
@@ -52,3 +55,5 @@ void *set_calloc(size_t n, size_t size);
|
|||||||
* See also: set_malloc()
|
* See also: set_malloc()
|
||||||
*/
|
*/
|
||||||
void *set_realloc(size_t n);
|
void *set_realloc(size_t n);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
18
src/list.c
18
src/list.c
@@ -1,5 +1,6 @@
|
|||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
void set_ll_append(struct SETBlockMeta *head, struct SETBlockMeta *next)
|
void set_ll_append(struct SETBlockMeta *head, struct SETBlockMeta *next)
|
||||||
@@ -23,20 +24,27 @@ void set_ll_free_all(struct SETBlockMeta *head)
|
|||||||
|
|
||||||
struct SETBlockMeta *set_ll_free_one(struct SETBlockMeta *head, void *address)
|
struct SETBlockMeta *set_ll_free_one(struct SETBlockMeta *head, void *address)
|
||||||
{
|
{
|
||||||
struct SETBlockMeta *meta = address - (sizeof(struct SETBlockMeta));
|
struct SETBlockMeta *meta =
|
||||||
|
(struct SETBlockMeta *)(address - (sizeof(struct SETBlockMeta)));
|
||||||
|
|
||||||
if (meta == head)
|
if (meta->prev == NULL)
|
||||||
{
|
{
|
||||||
struct SETBlockMeta *ret = meta->next;
|
struct SETBlockMeta *ret = meta->next;
|
||||||
ret->prev = NULL;
|
if (ret)
|
||||||
ret->end = meta->end;
|
{
|
||||||
|
ret->prev = NULL;
|
||||||
|
ret->end = meta->end;
|
||||||
|
}
|
||||||
free(meta);
|
free(meta);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
meta->prev->next = meta->next;
|
meta->prev->next = meta->next;
|
||||||
if (meta->next)
|
|
||||||
|
if (meta->next != NULL)
|
||||||
meta->next->prev = meta->prev;
|
meta->next->prev = meta->prev;
|
||||||
|
else
|
||||||
|
head->end = meta->prev;
|
||||||
|
|
||||||
free(meta);
|
free(meta);
|
||||||
|
|
||||||
|
@@ -86,7 +86,7 @@ static void dispatch_single_test(struct SETest *test)
|
|||||||
{
|
{
|
||||||
test->function(test);
|
test->function(test);
|
||||||
log_test_summary(test);
|
log_test_summary(test);
|
||||||
// set_free_all();
|
set_free_all();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ char *format_string(const char *fmt, ...)
|
|||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
size_t size = vsnprintf(NULL, 0, fmt, args);
|
size_t size = vsnprintf(NULL, 0, fmt, args);
|
||||||
char *out = (char *)malloc(size + 1);
|
char *out = (char *)set_malloc(size + 1);
|
||||||
|
|
||||||
if (!out)
|
if (!out)
|
||||||
{
|
{
|
||||||
@@ -48,12 +48,14 @@ int create_shared_suit_space(size_t size)
|
|||||||
void *set_malloc(size_t n)
|
void *set_malloc(size_t n)
|
||||||
{
|
{
|
||||||
void *blocks = malloc(n + sizeof(struct SETBlockMeta));
|
void *blocks = malloc(n + sizeof(struct SETBlockMeta));
|
||||||
struct SETBlockMeta *meta = blocks;
|
struct SETBlockMeta *meta = (struct SETBlockMeta *)blocks;
|
||||||
meta->next = NULL;
|
meta->next = NULL;
|
||||||
|
meta->prev = NULL;
|
||||||
|
|
||||||
if (block_meta_head == NULL)
|
if (block_meta_head == NULL)
|
||||||
{
|
{
|
||||||
meta->end = meta;
|
meta->end = meta;
|
||||||
|
block_meta_head = meta;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -32,6 +32,7 @@ TEST(Faculty_Negative)
|
|||||||
{
|
{
|
||||||
ASSERT_EQ(fac(-2), 1);
|
ASSERT_EQ(fac(-2), 1);
|
||||||
ASSERT_EQ(fac(0), 1);
|
ASSERT_EQ(fac(0), 1);
|
||||||
|
ASSERT_TRUE_MSG(false, "Hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
SUIT_SETUP(Basic_Setup)
|
SUIT_SETUP(Basic_Setup)
|
||||||
@@ -61,6 +62,7 @@ TEST(Other_Basic)
|
|||||||
TEST(Other_With_Malloc)
|
TEST(Other_With_Malloc)
|
||||||
{
|
{
|
||||||
int *some_array = set_malloc(20 * sizeof(int));
|
int *some_array = set_malloc(20 * sizeof(int));
|
||||||
|
int *array = set_malloc(20);
|
||||||
|
|
||||||
for (int i = 0; i < 20; i++)
|
for (int i = 0; i < 20; i++)
|
||||||
{
|
{
|
||||||
@@ -73,7 +75,11 @@ TEST(Other_With_Malloc)
|
|||||||
}
|
}
|
||||||
fprintf(stdout, ".\n");
|
fprintf(stdout, ".\n");
|
||||||
|
|
||||||
ASSERT_TRUE(true);
|
set_free(array);
|
||||||
|
set_free(some_array);
|
||||||
|
|
||||||
|
void *some_other = set_malloc(15);
|
||||||
|
ASSERT_TRUE(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SUIT_ST(Other, Basic_Setup, EMPTY)
|
SUIT_ST(Other, Basic_Setup, EMPTY)
|
||||||
|
12
testtest.cpp
Normal file
12
testtest.cpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#include "set.h"
|
||||||
|
#include "set_asserts.h"
|
||||||
|
|
||||||
|
NO_SETUP;
|
||||||
|
|
||||||
|
NO_TEAR_DOWN;
|
||||||
|
|
||||||
|
TEST(Basic) { ASSERT_EQ(1, 1); }
|
||||||
|
|
||||||
|
SUIT(Basic) { ADD_TEST(Basic); }
|
||||||
|
|
||||||
|
BUNDLE() { ADD_SUIT(Basic); }
|
Reference in New Issue
Block a user