Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/vczip/tests/tvcmtf.c
1810 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 2003-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Phong Vo <[email protected]> *
18
* Glenn Fowler <[email protected]> *
19
* *
20
***********************************************************************/
21
#include "vctest.h"
22
23
int main()
24
{
25
char *tar, *del, *t;
26
Vcodex_t *vc;
27
ssize_t k, n;
28
29
tar = "00000011111122222abc012000000111111222222012abc";
30
/* MTF: O0000010000020000abc555200000200000200000222555
31
ASCII: O 1 2 abc
32
POS: 01234567890123456789012345678901234567890123456
33
*/
34
35
if(!(vc = vcopen(0, Vcmtf, "0", 0, VC_ENCODE)) )
36
terror("Cannot open Vcmtf handle");
37
38
if((n = vcapply(vc, tar, strlen(tar), &del)) <= 0)
39
terror("Vcmtf0 failed");
40
41
if(!(vc = vcopen(0, Vcmtf, "0", 0, VC_DECODE)) )
42
terror("Cannot open Vcunmtf0 handle");
43
if((n = vcapply(vc, del, n, &t)) != strlen(tar) )
44
terror("Vcunmtf0 returns wrong size");
45
for(k = 0; k < n; ++k)
46
if(t[k] != tar[k])
47
terror("Vcunmtf0 computed bad byte");
48
49
tar = "00000011111122222abc012000000111111222222012abc";
50
/* MTS: 01000011000021000abc550210000210000210000220555
51
ASCII: O 1 2 abc
52
POS: 01234567890123456789012345678901234567890123456
53
*/
54
55
if(!(vc = vcopen(0, Vcmtf, 0, 0, VC_ENCODE)) )
56
terror("Cannot open Vcmtf1 handle");
57
58
if((n = vcapply(vc, tar, strlen(tar), &del)) <= 0)
59
terror("Vcmtf1 failed");
60
61
if(!(vc = vcopen(0, Vcmtf, 0, 0, VC_DECODE)) )
62
terror("Cannot open Vcunmtf1 handle");
63
if((n = vcapply(vc, del, n, &t)) != strlen(tar) )
64
terror("Vcunmtf returns wrong size");
65
for(k = 0; k < n; ++k)
66
if(t[k] != tar[k])
67
terror("Vcunmtf computed bad byte");
68
69
exit(0);
70
}
71
72