Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/vczip/tests/tvcrle.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 = "000011111a0b1c2000";
30
31
if(!(vc = vcopen(0, Vcrle, 0, 0, VC_ENCODE)) )
32
terror("Cannot open Vcrle handle");
33
34
if((n = vcapply(vc, tar, strlen(tar), &del)) <= 0)
35
terror("Vcrle failed");
36
37
if(!(vc = vcopen(0, Vcrle, 0, 0, VC_DECODE)) )
38
terror("Cannot open Vcunrle handle");
39
if((n = vcapply(vc, del, n, &t)) != strlen(tar) )
40
terror("Vcunrle returns wrong size");
41
for(k = 0; k < n; ++k)
42
if(t[k] != tar[k])
43
terror("Vcunrle computed bad byte");
44
45
if(!(vc = vcopen(0, Vcrle, "0", 0, VC_ENCODE)) )
46
terror("Cannot open Vcrle0 handle");
47
48
if((n = vcapply(vc, tar, strlen(tar), &del)) <= 0)
49
terror("Vcrle failed2");
50
51
if(!(vc = vcopen(0, Vcrle, "0", 0, VC_DECODE)) )
52
terror("Cannot open Vcunrle0 handle2");
53
if((n = vcapply(vc, del, n, &t)) != strlen(tar) )
54
terror("Vcunrle0 returns wrong size2");
55
for(k = 0; k < n; ++k)
56
if(t[k] != tar[k])
57
terror("Vcunrle0 computed bad byte2");
58
59
exit(0);
60
}
61
62