blob: 0c443b5eb7745a01bb54a2b80c91c3483fa7a304 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include <stdio.h>
#include <string.h>
#include "lily-test.h"
#include "tests.h"
// basic assertion
lily_test wrap_assert_msg(int statement, const char *message)
{
// if you move the location of this line, BE SURE TO UPDATE THE
// TEST BELOW so that it expects the correct line!
lily_assert_msg(statement, message);
return LILY_SUCCESS;
}
const char* basic_assertion()
{
lily_test result = wrap_assert_msg(1, "should succeed");
if (result.error != 0)
return "assert_msg() incorrectly returned non-zero error on true statement!";
result = wrap_assert_msg(0, "should fail");
if (result.error == 0)
return "assert_msg() incorrectly returned zero error on false statement!";
if (strcmp(result.message, "should fail") != 0)
return "assert_msg() returned with incorrect message!";
if (strcmp(result.location, "tests/assertions.c:12") != 0)
return "assert_msg() returned with incorrect location!";
return 0;
}
|