-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_packer.c
50 lines (33 loc) · 1.03 KB
/
test_packer.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
#include <core/system/packer.h>
#include <core/system/memory.h>
#include <stdio.h>
#include <stdlib.h>
#include "test.h"
int main(int argc, char **argv)
{
BEGIN_TESTS();
int expected_value;
int actual_value;
void *buffer;
expected_value = 42;
actual_value = 100;
buffer = core_memory_allocate(sizeof(expected_value), -1);
struct core_packer packer;
core_packer_init(&packer, CORE_PACKER_OPERATION_PACK, buffer);
core_packer_process(&packer, &expected_value, sizeof(expected_value));
core_packer_destroy(&packer);
core_packer_init(&packer, CORE_PACKER_OPERATION_UNPACK, buffer);
/*
printf("DEBUG unpacking in test\n");
*/
core_packer_process(&packer, &actual_value, sizeof(actual_value));
core_packer_destroy(&packer);
/*
printf("DEBUG actual_value %d expected_value %d\n",
actual_value, expected_value);
*/
TEST_INT_EQUALS(actual_value, expected_value);
core_memory_free(buffer, -1);
END_TESTS();
return 0;
}