-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvalue_testcases.c
63 lines (42 loc) · 1.52 KB
/
value_testcases.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
59
60
61
62
63
/*
* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2020 Ericsson AB
*/
#include "utest.h"
#include <paf_value.h>
TESTSUITE(value, NULL, NULL)
TESTCASE(value, int64_equal)
{
struct paf_value *int_17_value = paf_value_int64_create(-17);
struct paf_value *int_42_0_value = paf_value_int64_create(42);
struct paf_value *int_42_1_value = paf_value_int64_create(42);
CHK(paf_value_equal(int_17_value, int_17_value));
CHK(!paf_value_equal(int_17_value, int_42_0_value));
CHK(paf_value_equal(int_42_0_value, int_42_1_value));
paf_value_destroy(int_17_value);
paf_value_destroy(int_42_0_value);
paf_value_destroy(int_42_1_value);
return UTEST_SUCCESS;
}
TESTCASE(value, str_equal)
{
struct paf_value *str_a_value = paf_value_str_create("a");
struct paf_value *str_b_0_value = paf_value_str_create("boo");
struct paf_value *str_b_1_value = paf_value_str_create("boo");
CHK(paf_value_equal(str_a_value, str_a_value));
CHK(!paf_value_equal(str_a_value, str_b_0_value));
CHK(paf_value_equal(str_b_0_value, str_b_1_value));
paf_value_destroy(str_a_value);
paf_value_destroy(str_b_0_value);
paf_value_destroy(str_b_1_value);
return UTEST_SUCCESS;
}
TESTCASE(value, equal_different_type)
{
struct paf_value *int_value = paf_value_int64_create(42);
struct paf_value *str_value = paf_value_str_create("foo");
CHK(!paf_value_equal(int_value, str_value));
paf_value_destroy(int_value);
paf_value_destroy(str_value);
return UTEST_SUCCESS;
}