Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/cmd/vczip/tests/tvcdelta.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 *src, *tar, *del, *t;
26
Vcdisc_t disc;
27
Vcodex_t *vc;
28
ssize_t k, n;
29
30
src = "the big cat and the little cats jump around the big sleeping dog";
31
tar = "the little dogs and the big dog jump around the sleeping big cat";
32
33
VCDISC(&disc, src, strlen(src), 0);
34
35
if(!(vc = vcopen(&disc, Vcdelta, 0, 0, VC_ENCODE)) )
36
terror("Cannot open Vcdelta handle");
37
38
if((n = vcapply(vc, tar, strlen(tar), &del)) <= 0)
39
terror("Vcdelta failed");
40
if(n >= strlen(tar) )
41
terror("Did not compress data");
42
43
if(!(vc = vcopen(&disc, Vcdelta, 0, 0, VC_DECODE)) )
44
terror("Cannot open decoding handle");
45
if((n = vcapply(vc, del, n, &t)) != strlen(tar) )
46
terror("Decoding returns wrong size");
47
for(k = 0; k < n; ++k)
48
if(t[k] != tar[k])
49
terror("Decoding failed");
50
51
exit(0);
52
}
53
54