Add tests for pointer comparison
This commit is contained in:
parent
498a78cd9f
commit
6c30e282ef
@ -3,6 +3,7 @@
|
||||
#include <sys/wait.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
#define TT_FAIL(error, ...) dprintf(tt_pipe[1], "\"%s\" Line %d: %s >> " error "\n", tt_current->filename, __LINE__, tt_current->name, ##__VA_ARGS__);
|
||||
@ -56,6 +57,8 @@
|
||||
#define ASSERT_EQ_CHR(lhs, rhs) ASSERT_EQUAL(char, "c", lhs, rhs)
|
||||
#define ASSERT_NEQ_CHR(lhs, rhs) ASSERT_NOT_EQUAL(char, "c", lhs, rhs)
|
||||
#define ASSERT_EQ_STR(lhs, rhs, n) ASSERT_STRN(lhs, rhs, n)
|
||||
#define ASSERT_EQ_PTR(lhs, rhs) ASSERT_EQUAL(uintptr_t, PRIxPTR, lhs, rhs)
|
||||
#define ASSERT_NEQ_PTR(lhs, rhs) ASSERT_NOT_EQUAL(uintptr_t, PRIxPTR, lhs, rhs)
|
||||
|
||||
#define TEST(name) \
|
||||
int ttt_##name(); \
|
||||
|
@ -46,3 +46,23 @@ TEST(FAIL_two_equal_strings)
|
||||
{
|
||||
ASSERT_EQ_STR("Hello", "World", 5);
|
||||
}
|
||||
|
||||
int a, b;
|
||||
|
||||
TEST(two_equal_pointers)
|
||||
{
|
||||
ASSERT_EQ_PTR(&a, &a);
|
||||
}
|
||||
TEST(FAIL_two_equal_pointers)
|
||||
{
|
||||
ASSERT_EQ_PTR(&a, &b);
|
||||
}
|
||||
|
||||
TEST(two_different_pointers)
|
||||
{
|
||||
ASSERT_NEQ_PTR(&a, &b);
|
||||
}
|
||||
TEST(FAIL_two_different_pointers)
|
||||
{
|
||||
ASSERT_NEQ_PTR(&a, &a);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user