C Project Template
Loading...
Searching...
No Matches
test_TextCompress.h
1#ifndef TEST_TEXTCOMPRESS_H
2#define TEST_TEXTCOMPRESS_H
3#include "acutest.h"
4#include "TextCompress.h"
5#include "utils.h"
6#include <string.h>
7
8void text_hash(void){
9 que pinT;
10 que pinH;
11
12 char text[2000]="okayokayokay\0";
13 int textlen = strlen(text);
14 TextCompressMark(text, textlen, &pinT, &pinH);
15
16 TEST_CHECK(text[strlen(text)]=='\0');
17 TEST_CHECK(pinT.head == 0); TEST_MSG("Got %d", pinT.head);
18 TEST_CHECK(pinH.head == 0); TEST_MSG("Got %d", pinH.head);
19 TEST_CHECK(pinT.tail == 0); TEST_MSG("Got %d", pinT.tail);
20 TEST_CHECK(pinH.tail == 0); TEST_MSG("Got %d", pinH.tail);
21
22 TEST_CHECK(peek_que(&pinT) == 3);
23 TEST_CHECK(peek_que(&pinH) == 8);
24
25 PrintCompressedText(text, textlen, &pinT, &pinH);
26
27 kill_que(&pinT);
28 kill_que(&pinH);
29}
30
31void text_compressed(void){
32 que pinT;
33 que pinH;
34
35 char text[2000]="JJJJJJ\0";
36 int textlen = strlen(text);
37 TextCompressMark(text, textlen, &pinT, &pinH);
38
39
40 TEST_CHECK(pinT.head == 0); TEST_MSG("Got %d", pinT.head);
41 TEST_CHECK(pinH.head == 0); TEST_MSG("Got %d", pinH.head);
42 TEST_CHECK(pinT.tail == 2); TEST_MSG("Got %d", pinT.tail);
43 TEST_CHECK(pinH.tail == 2); TEST_MSG("Got %d", pinH.tail);
44
45 TEST_CHECK(peek_que(&pinT) == 0);
46 TEST_CHECK(peek_que(&pinH) == 5);
47
48 PrintCompressedText(text, textlen, &pinT, &pinH);
49
50 kill_que(&pinT);
51 kill_que(&pinH);
52}
53
54void test_compressed2(void){
55 que pinT;
56 que pinH;
57
58 char text[4000]="CCRRRWCRRRRRWQAWRVRCECCrCCRCWWWVWgCCCCCCiCCEWRCCCRCRWRRRRCWWWWRCCWWRRWCWRRWUWRCRCRWCWWgWWRRoWCWTCRRCWWCRWWRCWCCRCCCCRNWCRCRWcRWCXWRCRWWCCWRRRVWWRCCCCOCDCCCWRWCRRWCURhWCRRCCWCRRCWRCWFRRCRRCRCNWRCCCCOCRCRRCCCRRCRCWRWCWRCCCCDCRWRCCWCWCWCCCRRCWRWWCWCCWZRkRWCRCjMRRCWRCWVCWYWCWCWVCRRCCRRNWaJECRCCWCWWRCCRnRRRWWCCCRRRWCWoWCdCRCECCCWWRCCWCCWRRCRWRRWRjWRCmCWnCRCCRRWWRWCKCRRWRgWWWCtRWNCGARWCCrRCCRCrWCCRRCWiHWWWWRCRWRRJDCCCBRRWRRpCWWRRRRRsCCnRWRWRCCRRCCCWCRCCWxRRWRPCWWRRRWWRCCWRRWRWCRHCbCRCRRRCCWCRCWRWRWWCWCWCCWWCWCCWRWWWRCCWRWWWRWdCRCaRRNERCRWMRRWRCNCRRkCyWCRCCWRWCCCRWiRCWCCRWWRWCRRWWCCCWWRCRCRRCCRRRLhORRWCWJCRWCWNUWCpWECWCWWCCCWeCRRRRCCCRMCRWWRHCWCiCWCCCRPRRcWCWWCWWHFWCRaRCCRR\0";
59
60 TextCompressMark(text, strlen(text), &pinT, &pinH);
61 TEST_CHECK(pinT.arr.len == 2); TEST_MSG("Got %d", pinT.arr.len);
62 TEST_CHECK(pinH.arr.len == 2); TEST_MSG("Got %d", pinH.arr.len);
63
64 TEST_CHECK(pinT.arr.i[0] == 3);
65 TEST_CHECK(pinT.arr.i[1] == 4);
66
67}
68
69#endif
Definition utils.h:53
General Utilities for C language.