1#ifndef TEST_TEXTCOMPRESS_H
2#define TEST_TEXTCOMPRESS_H
4#include "TextCompress.h"
12 char text[2000]=
"okayokayokay\0";
13 int textlen = strlen(text);
14 TextCompressMark(text, textlen, &pinT, &pinH);
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);
22 TEST_CHECK(peek_que(&pinT) == 3);
23 TEST_CHECK(peek_que(&pinH) == 8);
25 PrintCompressedText(text, textlen, &pinT, &pinH);
31void text_compressed(
void){
35 char text[2000]=
"JJJJJJ\0";
36 int textlen = strlen(text);
37 TextCompressMark(text, textlen, &pinT, &pinH);
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);
45 TEST_CHECK(peek_que(&pinT) == 0);
46 TEST_CHECK(peek_que(&pinH) == 5);
48 PrintCompressedText(text, textlen, &pinT, &pinH);
54void test_compressed2(
void){
58 char text[4000]=
"CCRRRWCRRRRRWQAWRVRCECCrCCRCWWWVWgCCCCCCiCCEWRCCCRCRWRRRRCWWWWRCCWWRRWCWRRWUWRCRCRWCWWgWWRRoWCWTCRRCWWCRWWRCWCCRCCCCRNWCRCRWcRWCXWRCRWWCCWRRRVWWRCCCCOCDCCCWRWCRRWCURhWCRRCCWCRRCWRCWFRRCRRCRCNWRCCCCOCRCRRCCCRRCRCWRWCWRCCCCDCRWRCCWCWCWCCCRRCWRWWCWCCWZRkRWCRCjMRRCWRCWVCWYWCWCWVCRRCCRRNWaJECRCCWCWWRCCRnRRRWWCCCRRRWCWoWCdCRCECCCWWRCCWCCWRRCRWRRWRjWRCmCWnCRCCRRWWRWCKCRRWRgWWWCtRWNCGARWCCrRCCRCrWCCRRCWiHWWWWRCRWRRJDCCCBRRWRRpCWWRRRRRsCCnRWRWRCCRRCCCWCRCCWxRRWRPCWWRRRWWRCCWRRWRWCRHCbCRCRRRCCWCRCWRWRWWCWCWCCWWCWCCWRWWWRCCWRWWWRWdCRCaRRNERCRWMRRWRCNCRRkCyWCRCCWRWCCCRWiRCWCCRWWRWCRRWWCCCWWRCRCRRCCRRRLhORRWCWJCRWCWNUWCpWECWCWWCCCWeCRRRRCCCRMCRWWRHCWCiCWCCCRPRRcWCWWCWWHFWCRaRCCRR\0";
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);
64 TEST_CHECK(pinT.arr.i[0] == 3);
65 TEST_CHECK(pinT.arr.i[1] == 4);
General Utilities for C language.