-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvvs_example.c
58 lines (48 loc) · 1.4 KB
/
vvs_example.c
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* An example of VVS
*
* @author Sunglok Choi (http://sites.google.com/site/sunglok)
* @version 0.2 (05/22/2019)
*/
#include <string.h>
#include <math.h>
// Exceptions by 'assert' are not activated if you enable the following definition
//#define VVS_NO_ASSERT
#include "vvs.h"
/**
* An test function for Example #1
*/
void testExample1()
{
int year = 1982;
int month = 3;
int day = 29;
char name[] = "Sunglok";
// Basic examples
VVS_CHECK_TRUE(year == 1982);
VVS_CHECK_FALSE(month == 4);
VVS_CHECK_EQUAL(day, 29);
//VVS_CHECK_EQUAL(day, 30); // Halt by 'assert' in DEBUG mode if enabled
// Examples for strings
VVS_CHECK_TRUE(strcmp(name, "Sunglok") == 0);
VVS_CHECK_FALSE(strcmp(name, "Starmi") == 0);
}
/**
* An test function for Example #2
*/
void testExample2()
{
double pi = 3.141592;
// Examples for real numbers
VVS_CHECK_FALSE(atan2(0.0, -1.0) == pi); // False due to small difference
//VVS_CHECK_RANGE(atan2(0.0, -1.0), pi, 1e-9); // Halt by 'assert' in DEBUG mode if enabled
VVS_CHECK_NEAR(atan2(0.0, -1.0), pi); // True up to tolerance, 'VVS_EPSILON'
}
int main()
{
// Run test functions
VVS_RUN_TEST(testExample1());
VVS_NUN_TEST(testExample1()); // Do not run, 'NUN' instead of 'RUN'
VVS_RUN_TEST(testExample2());
return 0;
}