Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/vczip/tests/tvcbwt.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
#if 1
30
tar = "00000011111122222abc012000000111111222222012abc";
31
#else
32
/* for debugging, here are the various data for "panama":
33
** BW transform: \005npmaaaa
34
** base[]: 'a' 0, 'm' 3, 'n' 4, 'p' 5
35
** offset[]: 0 0 0 0 1 0 2
36
*/
37
tar = "panama";
38
#endif
39
40
if(!(vc = vcopen(0, Vcbwt, 0, 0, VC_ENCODE)) )
41
terror("Cannot open Vcbwt handle");
42
43
if((n = vcapply(vc, tar, strlen(tar), &del)) <= 0)
44
terror("Vcbwt failed");
45
46
if(!(vc = vcopen(0, Vcbwt, 0, 0, VC_DECODE)) )
47
terror("Cannot open Vcbwt handle");
48
if((n = vcapply(vc, del, n, &t)) != strlen(tar) )
49
terror("Vcunbwt returns wrong size");
50
for(k = 0; k < n; ++k)
51
if(t[k] != tar[k])
52
terror("Vcunbwt computed bad byte");
53
exit(0);
54
}
55
56