exip
Alpha 0.5.4
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
tests
check_contentIO.c
Go to the documentation of this file.
1
/*==================================================================*\
2
| EXIP - Embeddable EXI Processor in C |
3
|--------------------------------------------------------------------|
4
| This work is licensed under BSD 3-Clause License |
5
| The full license terms and conditions are located in LICENSE.txt |
6
\===================================================================*/
7
18
#include <stdlib.h>
19
#include <
check.h
>
20
#include "
headerDecode.h
"
21
#include "
bodyDecode.h
"
22
#include "
memManagement.h
"
23
24
/* BEGIN: header tests */
25
26
START_TEST
(test_decodeHeader)
27
{
28
EXIStream
testStream;
// Default options, no EXI cookie
29
char
buf[3];
30
errorCode
err =
EXIP_UNEXPECTED_ERROR
;
31
EXIStream
testStream2;
// Default options, with EXI cookie
32
char
buf2[7];
33
34
testStream.
context
.
bitPointer
= 0;
35
buf[0] = (char) 0x80;
36
buf[1] = (char) 0x60;
37
buf[2] = (char) 0x7C;
38
testStream.
buffer
.
buf
= buf;
39
testStream.
context
.
bufferIndx
= 0;
40
testStream.
buffer
.
bufLen
= 3;
41
testStream.
buffer
.
bufContent
= 3;
42
testStream.
buffer
.
ioStrm
.
readWriteToStream
=
NULL
;
43
testStream.
buffer
.
ioStrm
.
stream
=
NULL
;
44
initAllocList
(&testStream.
memList
);
45
makeDefaultOpts
(&testStream.
header
.
opts
);
46
47
err =
decodeHeader
(&testStream,
TRUE
);
48
fail_unless
(err ==
EXIP_OK
,
"decodeHeader returns error code %d"
, err);
49
fail_unless
(testStream.
header
.
has_cookie
== 0,
50
"decodeHeader founds EXI cookie"
);
51
fail_unless
(testStream.
header
.
has_options
== 0,
52
"decodeHeader founds options"
);
53
fail_unless
(testStream.
header
.
is_preview_version
== 0,
54
"decodeHeader founds preview version"
);
55
fail_unless
(testStream.
header
.
version_number
== 1,
56
"decodeHeader does not recognize version 1 of the stream"
);
57
58
testStream2.
context
.
bitPointer
= 0;
59
60
buf2[0] = (char) 36;
61
buf2[1] = (char) 69;
62
buf2[2] = (char) 88;
63
buf2[3] = (char) 73;
64
buf2[4] = (char) 0x80;
65
buf2[5] = (char) 0x60;
66
buf2[6] = (char) 0x7C;
67
68
testStream2.
buffer
.
buf
= buf2;
69
testStream2.
context
.
bufferIndx
= 0;
70
testStream2.
buffer
.
bufLen
= 7;
71
testStream2.
buffer
.
bufContent
= 7;
72
testStream2.
buffer
.
ioStrm
.
readWriteToStream
=
NULL
;
73
testStream2.
buffer
.
ioStrm
.
stream
=
NULL
;
74
75
err =
decodeHeader
(&testStream2,
TRUE
);
76
fail_unless
(err ==
EXIP_OK
,
"decodeHeader returns error code %d"
, err);
77
fail_unless
(testStream2.
header
.
has_cookie
== 1,
78
"decodeHeader does not found EXI cookie"
);
79
fail_unless
(testStream2.
header
.
has_options
== 0,
80
"decodeHeader founds options"
);
81
fail_unless
(testStream2.
header
.
is_preview_version
== 0,
82
"decodeHeader founds preview version"
);
83
fail_unless
(testStream2.
header
.
version_number
== 1,
84
"decodeHeader does not recognize version 1 of the stream"
);
85
}
86
END_TEST
87
88
/* END: header tests */
89
90
Suite
*
contentio_suite
(
void
)
91
{
92
Suite
*s =
suite_create
(
"ContentIO"
);
93
94
/* Header test case */
95
TCase
*tc_header =
tcase_create
(
"EXI Header"
);
96
tcase_add_test
(tc_header, test_decodeHeader);
97
suite_add_tcase
(s, tc_header);
98
return
s;
99
}
100
101
int
main
(
void
)
102
{
103
int
number_failed;
104
Suite
*s =
contentio_suite
();
105
SRunner
*sr =
srunner_create
(s);
106
#ifdef _MSC_VER
107
srunner_set_fork_status
(sr,
CK_NOFORK
);
108
#endif
109
srunner_run_all
(sr,
CK_NORMAL
);
110
number_failed =
srunner_ntests_failed
(sr);
111
srunner_free
(sr);
112
return
(number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
113
}
Generated on Thu Nov 27 2014 10:56:08 for exip by
1.8.4