swfmill 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.swfmill +0 -134
- data/README.rdoc +28 -8
- data/Rakefile +6 -5
- data/VERSION +1 -1
- data/ext/.gitignore +1 -0
- data/ext/buffer.h +95 -0
- data/ext/deflate.h +125 -0
- data/ext/extconf.rb +77 -43
- data/ext/inflate.h +82 -0
- data/ext/swfmill/.gitignore +3 -16
- data/ext/swfmill/AUTHORS +2 -1
- data/ext/swfmill/Makefile.in +2 -1
- data/ext/swfmill/NEWS +5 -0
- data/ext/swfmill/autogen.sh +7 -1
- data/ext/swfmill/configure +361 -275
- data/ext/swfmill/configure.ac +28 -20
- data/ext/swfmill/src/Makefile.am +93 -20
- data/ext/swfmill/src/Makefile.in +454 -170
- data/ext/swfmill/src/SWF.h +3 -0
- data/ext/swfmill/src/SWFFile.cpp +1 -1
- data/ext/swfmill/src/SWFShapeMaker.cpp +4 -3
- data/ext/swfmill/src/codegen/basics.xsl +2 -1
- data/ext/swfmill/src/codegen/header.xsl +3 -0
- data/ext/swfmill/src/codegen/parsexml.xsl +53 -2
- data/ext/swfmill/src/codegen/writexml.xsl +54 -1
- data/ext/swfmill/src/swfmill.cpp +52 -35
- data/ext/swfmill/src/swft/swft_import_jpeg.cpp +62 -16
- data/ext/swfmill/src/xslt/simple-elements.xslt +1 -0
- data/ext/swfmill/test/Makefile.in +2 -1
- data/ext/swfmill/test/xml/Makefile.in +2 -1
- data/ext/swfmill_ext.cc +12 -366
- data/ext/swfmill_ext_to_swf.cc +260 -0
- data/ext/swfmill_ext_to_swf.h +6 -0
- data/ext/swfmill_ext_to_xml.cc +262 -0
- data/ext/swfmill_ext_to_xml.h +6 -0
- data/ext/test/Makefile +16 -0
- data/ext/test/buffer_test.cc +84 -0
- data/ext/test/deflate_test.cc +61 -0
- data/ext/test/inflate_test.cc +84 -0
- data/ext/test/test.dat +0 -0
- data/lib/swfmill.rb +14 -23
- data/spec/swfmill_spec.rb +0 -123
- metadata +28 -17
- data/ext/swfmill/src/codegen/Makefile.am +0 -15
- data/ext/swfmill/src/codegen/Makefile.in +0 -346
- data/ext/swfmill/src/swft/Makefile.am +0 -55
- data/ext/swfmill/src/swft/Makefile.in +0 -717
- data/ext/swfmill/src/xslt/Makefile.am +0 -51
- data/ext/swfmill/src/xslt/Makefile.in +0 -536
- data/ext/swfmill/src/xslt/README +0 -19
- data/ext/swfmill/src/xslt/simple.cpp +0 -1686
@@ -0,0 +1,262 @@
|
|
1
|
+
#include "ruby.h"
|
2
|
+
#include "SWF.h"
|
3
|
+
#include "SWFReader.h"
|
4
|
+
#include "inflate.h"
|
5
|
+
|
6
|
+
extern VALUE rb_eSwfmill_Error;
|
7
|
+
extern VALUE rb_eSwfmill_EOFError;
|
8
|
+
|
9
|
+
#define SIGNATURE_SIZE 8
|
10
|
+
typedef struct {
|
11
|
+
VALUE string;
|
12
|
+
VALUE encoding;
|
13
|
+
bool compressed;
|
14
|
+
SWF::Header *header;
|
15
|
+
SWF::Context *context;
|
16
|
+
size_t datasize;
|
17
|
+
} swfmill_to_xml;
|
18
|
+
|
19
|
+
static void
|
20
|
+
stx_mark(swfmill_to_xml * const stx)
|
21
|
+
{
|
22
|
+
if(stx != NULL)
|
23
|
+
{
|
24
|
+
rb_gc_mark(stx->string);
|
25
|
+
rb_gc_mark(stx->encoding);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
static void
|
30
|
+
stx_free(swfmill_to_xml * const stx)
|
31
|
+
{
|
32
|
+
if(stx != NULL)
|
33
|
+
{
|
34
|
+
delete stx->header;
|
35
|
+
stx->header = NULL;
|
36
|
+
delete stx->context;
|
37
|
+
stx->context = NULL;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
static bool
|
42
|
+
stx_validate(const swfmill_to_xml * const stx)
|
43
|
+
{
|
44
|
+
if((RSTRING_LEN(stx->string) < SIGNATURE_SIZE) ||
|
45
|
+
(strncmp(RSTRING_PTR(stx->string), "CWS", 2) != 0 &&
|
46
|
+
strncmp(RSTRING_PTR(stx->string), "FWS", 2) != 0))
|
47
|
+
{
|
48
|
+
rb_raise(rb_eSwfmill_Error, "input is no SWF");
|
49
|
+
return false;
|
50
|
+
}
|
51
|
+
return true;
|
52
|
+
}
|
53
|
+
|
54
|
+
static void
|
55
|
+
stx_check_version(swfmill_to_xml * const stx)
|
56
|
+
{
|
57
|
+
stx->context = new SWF::Context;
|
58
|
+
stx->context->debugTrace = false;
|
59
|
+
stx->context->quiet = true;
|
60
|
+
|
61
|
+
stx->context->swfVersion = (int)RSTRING_PTR(stx->string)[3];
|
62
|
+
// fprintf(stderr, "swfVersion: %d\n", stx->context->swfVersion);
|
63
|
+
}
|
64
|
+
|
65
|
+
static void
|
66
|
+
stx_check_compressed(swfmill_to_xml * const stx)
|
67
|
+
{
|
68
|
+
stx->compressed = RSTRING_PTR(stx->string)[0] == 'C';
|
69
|
+
// fprintf(stderr, "compressed: %d\n", stx->compressed);
|
70
|
+
}
|
71
|
+
|
72
|
+
static void
|
73
|
+
stx_check_datasize(swfmill_to_xml * const stx)
|
74
|
+
{
|
75
|
+
stx->datasize = (size_t)RSTRING_PTR(stx->string)[4];
|
76
|
+
stx->datasize += (size_t)RSTRING_PTR(stx->string)[5] << 8;
|
77
|
+
stx->datasize += (size_t)RSTRING_PTR(stx->string)[6] << 16;
|
78
|
+
stx->datasize += (size_t)RSTRING_PTR(stx->string)[7] << 24;
|
79
|
+
// fprintf(stderr, "datasize: %d\n", stx->datasize);
|
80
|
+
|
81
|
+
if(stx->datasize != RSTRING_LEN(stx->string) - SIGNATURE_SIZE)
|
82
|
+
{
|
83
|
+
if((!stx->compressed) &&
|
84
|
+
(stx->datasize > RSTRING_LEN(stx->string) - SIGNATURE_SIZE))
|
85
|
+
{
|
86
|
+
stx->datasize = RSTRING_LEN(stx->string) - SIGNATURE_SIZE;
|
87
|
+
}
|
88
|
+
}
|
89
|
+
// fprintf(stderr, "fixed datasize: %d\n", stx->datasize);
|
90
|
+
}
|
91
|
+
|
92
|
+
static bool
|
93
|
+
stx_copy(swfmill_to_xml * const stx)
|
94
|
+
{
|
95
|
+
stx->string = rb_str_new(RSTRING_PTR(stx->string) + SIGNATURE_SIZE,
|
96
|
+
RSTRING_LEN(stx->string) - SIGNATURE_SIZE);
|
97
|
+
return true;
|
98
|
+
}
|
99
|
+
|
100
|
+
static bool
|
101
|
+
stx_decompress(swfmill_to_xml * const stx)
|
102
|
+
{
|
103
|
+
if(!stx->compressed)
|
104
|
+
{
|
105
|
+
return stx_copy(stx);
|
106
|
+
}
|
107
|
+
|
108
|
+
const unsigned char* buff = (const unsigned char*)RSTRING_PTR(stx->string) + SIGNATURE_SIZE;
|
109
|
+
const size_t size = RSTRING_LEN(stx->string) - SIGNATURE_SIZE;
|
110
|
+
Inflate inflate(buff, size, stx->datasize);
|
111
|
+
|
112
|
+
if(!inflate.decompress())
|
113
|
+
{
|
114
|
+
rb_raise(rb_eSwfmill_Error, "decompressing SWF");
|
115
|
+
return false;
|
116
|
+
}
|
117
|
+
|
118
|
+
stx->string = rb_str_new((const char*)inflate.data(), stx->datasize);
|
119
|
+
|
120
|
+
return true;
|
121
|
+
}
|
122
|
+
|
123
|
+
static bool
|
124
|
+
stx_read(swfmill_to_xml* const stx)
|
125
|
+
{
|
126
|
+
SWF::Reader reader((const unsigned char*)RSTRING_PTR(stx->string), RSTRING_LEN(stx->string));
|
127
|
+
|
128
|
+
stx->header = new SWF::Header;
|
129
|
+
stx->header->parse(&reader, RSTRING_LEN(stx->string), stx->context);
|
130
|
+
|
131
|
+
switch(reader.getError())
|
132
|
+
{
|
133
|
+
case SWFR_ERROR:
|
134
|
+
rb_raise(rb_eSwfmill_Error, "unknown error while reading SWF");
|
135
|
+
return false;
|
136
|
+
case SWFR_EOF:
|
137
|
+
rb_raise(rb_eSwfmill_EOFError, "reached EOF while reading SWF");
|
138
|
+
return false;
|
139
|
+
}
|
140
|
+
|
141
|
+
return true;
|
142
|
+
}
|
143
|
+
|
144
|
+
static bool
|
145
|
+
stx_parse(swfmill_to_xml* const stx)
|
146
|
+
{
|
147
|
+
if(!stx_validate(stx))
|
148
|
+
{
|
149
|
+
return false;
|
150
|
+
}
|
151
|
+
stx_check_version(stx);
|
152
|
+
stx_check_compressed(stx);
|
153
|
+
stx_check_datasize(stx);
|
154
|
+
if(!stx_decompress(stx))
|
155
|
+
{
|
156
|
+
return false;
|
157
|
+
}
|
158
|
+
if(!stx_read(stx))
|
159
|
+
{
|
160
|
+
return false;
|
161
|
+
}
|
162
|
+
return true;
|
163
|
+
}
|
164
|
+
|
165
|
+
static void
|
166
|
+
stx_init_xml_memory()
|
167
|
+
{
|
168
|
+
xmlMemSetup((xmlFreeFunc)ruby_xfree,
|
169
|
+
(xmlMallocFunc)ruby_xmalloc,
|
170
|
+
(xmlReallocFunc)ruby_xrealloc,
|
171
|
+
strdup);
|
172
|
+
}
|
173
|
+
|
174
|
+
static void
|
175
|
+
stx_set_version_proparty(const swfmill_to_xml* const stx, xmlNodePtr root)
|
176
|
+
{
|
177
|
+
char temp[4];
|
178
|
+
snprintf(temp, sizeof(temp), "%i", stx->context->swfVersion);
|
179
|
+
xmlSetProp(root, (const xmlChar*)"version", (const xmlChar*)temp);
|
180
|
+
}
|
181
|
+
|
182
|
+
static void
|
183
|
+
stx_set_compressed_proparty(const swfmill_to_xml* const stx, xmlNodePtr root)
|
184
|
+
{
|
185
|
+
char temp[4];
|
186
|
+
snprintf(temp, sizeof(temp), "%i", stx->compressed ? 1 : 0);
|
187
|
+
xmlSetProp(root, (const xmlChar*)"compressed", (const xmlChar*)temp);
|
188
|
+
}
|
189
|
+
|
190
|
+
static void
|
191
|
+
stx_set_encoding(swfmill_to_xml* const stx)
|
192
|
+
{
|
193
|
+
stx->context->convertEncoding = true;
|
194
|
+
stx->context->swf_encoding = StringValueCStr(stx->encoding);
|
195
|
+
// fprintf(stderr, "%s\n", stx->context->swf_encoding);
|
196
|
+
}
|
197
|
+
|
198
|
+
static VALUE
|
199
|
+
stx_dump(const swfmill_to_xml* const stx, xmlDocPtr doc)
|
200
|
+
{
|
201
|
+
VALUE xml = Qnil;
|
202
|
+
char* xml_data = NULL;
|
203
|
+
int xml_size = 0;
|
204
|
+
|
205
|
+
xmlDocDumpMemoryEnc(doc, (xmlChar**)&xml_data, &xml_size, "UTF-8");
|
206
|
+
if(xml_size > 0)
|
207
|
+
{
|
208
|
+
xml = rb_str_new(xml_data, xml_size);
|
209
|
+
}
|
210
|
+
if(xml_data != NULL)
|
211
|
+
{
|
212
|
+
xmlFree(xml_data);
|
213
|
+
}
|
214
|
+
return xml;
|
215
|
+
}
|
216
|
+
|
217
|
+
static VALUE
|
218
|
+
stx_to_string(swfmill_to_xml* const stx)
|
219
|
+
{
|
220
|
+
VALUE xml = Qnil;
|
221
|
+
xmlDocPtr doc;
|
222
|
+
xmlNodePtr root;
|
223
|
+
stx_init_xml_memory();
|
224
|
+
|
225
|
+
doc = xmlNewDoc((const xmlChar*)"1.0");
|
226
|
+
root = doc->xmlRootNode = xmlNewDocNode(doc, NULL, (const xmlChar*)"swf", NULL);
|
227
|
+
|
228
|
+
stx_set_version_proparty(stx, root);
|
229
|
+
stx_set_compressed_proparty(stx, root);
|
230
|
+
stx_set_encoding(stx);
|
231
|
+
|
232
|
+
stx->header->writeXML(root, stx->context);
|
233
|
+
xml = stx_dump(stx, doc);
|
234
|
+
|
235
|
+
xmlFreeDoc(doc);
|
236
|
+
return xml;
|
237
|
+
}
|
238
|
+
|
239
|
+
/*
|
240
|
+
call-seq:
|
241
|
+
Swfmill.to_xml(string, encoding) -> String
|
242
|
+
*/
|
243
|
+
VALUE
|
244
|
+
swfmill_ext_to_xml(VALUE self, VALUE string, VALUE encoding)
|
245
|
+
{
|
246
|
+
swfmill_to_xml *stx;
|
247
|
+
|
248
|
+
Check_Type(string, T_STRING);
|
249
|
+
Check_Type(encoding, T_STRING);
|
250
|
+
|
251
|
+
Data_Make_Struct(rb_cData, swfmill_to_xml, stx_mark, stx_free, stx);
|
252
|
+
|
253
|
+
stx->string = string;
|
254
|
+
stx->encoding = encoding;
|
255
|
+
|
256
|
+
if(stx_parse(stx))
|
257
|
+
{
|
258
|
+
return stx_to_string(stx);
|
259
|
+
}
|
260
|
+
|
261
|
+
return Qnil;
|
262
|
+
}
|
data/ext/test/Makefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
OBJS = buffer_test.o inflate_test.o deflate_test.o
|
2
|
+
|
3
|
+
CXX = g++
|
4
|
+
CFLAGS = -g -O0 -I../ -I$(HOME)/include
|
5
|
+
LDFLAGS = -L$(HOME)/lib -lgtest_main -lz -lpthread
|
6
|
+
|
7
|
+
all: $(OBJS)
|
8
|
+
$(CXX) $(CFLAGS) $(LDFLAGS) -o test_all $(OBJS)
|
9
|
+
./test_all || rm ./test_all
|
10
|
+
|
11
|
+
.cc.o:
|
12
|
+
$(CXX) $(CFLAGS) -c $<
|
13
|
+
|
14
|
+
PHONY: check-syntax
|
15
|
+
check-syntax:
|
16
|
+
$(CXX) $(CFLAGS) -Wall -Wextra -pedantic -fsyntax-only $(CHK_SOURCES)
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#include <gtest/gtest.h>
|
2
|
+
#include "buffer.h"
|
3
|
+
|
4
|
+
class BufferTest : public testing::Test
|
5
|
+
{
|
6
|
+
};
|
7
|
+
|
8
|
+
TEST_F(BufferTest, Constructor)
|
9
|
+
{
|
10
|
+
buffer<char> temp(1);
|
11
|
+
}
|
12
|
+
|
13
|
+
TEST_F(BufferTest, CopyConstructor)
|
14
|
+
{
|
15
|
+
buffer<char> tmp1(5);
|
16
|
+
tmp1.append("54321", 5);
|
17
|
+
|
18
|
+
buffer<char> tmp2 = tmp1;
|
19
|
+
ASSERT_EQ(0, memcmp("54321", tmp2.ptr(), tmp2.size()));
|
20
|
+
}
|
21
|
+
|
22
|
+
TEST_F(BufferTest, Ptr)
|
23
|
+
{
|
24
|
+
buffer<char> temp(1);
|
25
|
+
ASSERT_TRUE(temp.ptr() != NULL);
|
26
|
+
}
|
27
|
+
|
28
|
+
TEST_F(BufferTest, Size)
|
29
|
+
{
|
30
|
+
buffer<char> temp(1);
|
31
|
+
ASSERT_EQ(0, temp.size());
|
32
|
+
}
|
33
|
+
|
34
|
+
TEST_F(BufferTest, Capacity)
|
35
|
+
{
|
36
|
+
buffer<char> temp(1);
|
37
|
+
ASSERT_EQ(1, temp.capacity());
|
38
|
+
}
|
39
|
+
|
40
|
+
TEST_F(BufferTest, Raise_Capacity)
|
41
|
+
{
|
42
|
+
buffer<char> tmp1(4);
|
43
|
+
|
44
|
+
tmp1.append("12345", 5);
|
45
|
+
EXPECT_EQ(5, tmp1.size());
|
46
|
+
EXPECT_EQ(11, tmp1.capacity());
|
47
|
+
|
48
|
+
buffer<char> tmp2(2);
|
49
|
+
|
50
|
+
tmp2.append("12345", 5);
|
51
|
+
EXPECT_EQ(5, tmp2.size());
|
52
|
+
EXPECT_EQ(9, tmp2.capacity());
|
53
|
+
}
|
54
|
+
|
55
|
+
TEST_F(BufferTest, Append)
|
56
|
+
{
|
57
|
+
const char* data = "abc";
|
58
|
+
buffer<char> temp;
|
59
|
+
|
60
|
+
ASSERT_EQ(3, temp.append(data, strlen(data)));
|
61
|
+
ASSERT_EQ(0, memcmp(data, temp.ptr(), temp.size()));
|
62
|
+
}
|
63
|
+
|
64
|
+
TEST_F(BufferTest, Reserve)
|
65
|
+
{
|
66
|
+
buffer<char> temp(3);
|
67
|
+
temp.append("1234", 4);
|
68
|
+
ASSERT_EQ(3, temp.reserve(3));
|
69
|
+
ASSERT_EQ(3, temp.size());
|
70
|
+
ASSERT_EQ(3, temp.capacity());
|
71
|
+
ASSERT_EQ(0, memcmp("123", temp.ptr(), temp.size()));
|
72
|
+
}
|
73
|
+
|
74
|
+
TEST_F(BufferTest, Resize)
|
75
|
+
{
|
76
|
+
buffer<char> temp(5);
|
77
|
+
|
78
|
+
temp.append("12345", 5);
|
79
|
+
temp.resize(3);
|
80
|
+
ASSERT_EQ(0, memcmp("123", temp.ptr(), temp.size()));
|
81
|
+
|
82
|
+
temp.resize(10);
|
83
|
+
ASSERT_EQ(12, temp.capacity());
|
84
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
#include <fstream>
|
3
|
+
#include <gtest/gtest.h>
|
4
|
+
#include "deflate.h"
|
5
|
+
|
6
|
+
class DeflateTest : public testing::Test
|
7
|
+
{
|
8
|
+
protected:
|
9
|
+
|
10
|
+
void SetUp()
|
11
|
+
{
|
12
|
+
read_file("test.dat", testdata, testdata_size);
|
13
|
+
testdata_length = 256;
|
14
|
+
|
15
|
+
testbuff = new unsigned char[testdata_length];
|
16
|
+
for(size_t i=0; i<testdata_length; i++)
|
17
|
+
{
|
18
|
+
testbuff[i] = i;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
void TearDown()
|
23
|
+
{
|
24
|
+
delete[] testdata;
|
25
|
+
delete[] testbuff;
|
26
|
+
}
|
27
|
+
|
28
|
+
void read_file(const char* const filename, char*& data, size_t& length)
|
29
|
+
{
|
30
|
+
std::ifstream is;
|
31
|
+
|
32
|
+
is.open(filename, std::ios::binary);
|
33
|
+
|
34
|
+
is.seekg(0, std::ios::end);
|
35
|
+
length = is.tellg();
|
36
|
+
is.seekg(0, std::ios::beg);
|
37
|
+
|
38
|
+
data = new char[length];
|
39
|
+
is.read(data, length);
|
40
|
+
is.close();
|
41
|
+
}
|
42
|
+
|
43
|
+
char* testdata;
|
44
|
+
size_t testdata_size;
|
45
|
+
size_t testdata_length;
|
46
|
+
unsigned char* testbuff;
|
47
|
+
|
48
|
+
};
|
49
|
+
|
50
|
+
TEST_F(DeflateTest, Constructor)
|
51
|
+
{
|
52
|
+
Deflate d((unsigned char*)testdata, testdata_size);
|
53
|
+
}
|
54
|
+
|
55
|
+
TEST_F(DeflateTest, compress)
|
56
|
+
{
|
57
|
+
Deflate d(testbuff, testdata_length);
|
58
|
+
EXPECT_TRUE(d.compress());
|
59
|
+
ASSERT_TRUE(memcmp(d.data(), testdata, testdata_length) == 0);
|
60
|
+
ASSERT_EQ(testdata_size, d.size());
|
61
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#include <iostream>
|
2
|
+
#include <fstream>
|
3
|
+
#include <gtest/gtest.h>
|
4
|
+
#include "inflate.h"
|
5
|
+
|
6
|
+
class InflateTest : public testing::Test
|
7
|
+
{
|
8
|
+
protected:
|
9
|
+
|
10
|
+
void SetUp()
|
11
|
+
{
|
12
|
+
read_file("test.dat", testdata, testdata_size);
|
13
|
+
testdata_length = 256;
|
14
|
+
}
|
15
|
+
|
16
|
+
void TearDown()
|
17
|
+
{
|
18
|
+
delete[] testdata;
|
19
|
+
}
|
20
|
+
|
21
|
+
void read_file(const char* const filename, char*& data, size_t& length)
|
22
|
+
{
|
23
|
+
std::ifstream is;
|
24
|
+
|
25
|
+
is.open(filename, std::ios::binary);
|
26
|
+
|
27
|
+
is.seekg(0, std::ios::end);
|
28
|
+
length = is.tellg();
|
29
|
+
is.seekg(0, std::ios::beg);
|
30
|
+
|
31
|
+
data = new char[length];
|
32
|
+
is.read(data, length);
|
33
|
+
is.close();
|
34
|
+
}
|
35
|
+
|
36
|
+
char* testdata;
|
37
|
+
size_t testdata_size;
|
38
|
+
size_t testdata_length;
|
39
|
+
|
40
|
+
};
|
41
|
+
|
42
|
+
TEST_F(InflateTest, Constructor)
|
43
|
+
{
|
44
|
+
Inflate i((unsigned char*)testdata, testdata_size, testdata_length);
|
45
|
+
}
|
46
|
+
|
47
|
+
TEST_F(InflateTest, data)
|
48
|
+
{
|
49
|
+
Inflate i((unsigned char*)testdata, testdata_size, testdata_length);
|
50
|
+
ASSERT_TRUE(i.data() != NULL);
|
51
|
+
}
|
52
|
+
|
53
|
+
TEST_F(InflateTest, decompress)
|
54
|
+
{
|
55
|
+
Inflate i((unsigned char*)testdata, testdata_size, testdata_length);
|
56
|
+
ASSERT_TRUE(i.decompress());
|
57
|
+
}
|
58
|
+
|
59
|
+
TEST_F(InflateTest, decompress_1)
|
60
|
+
{
|
61
|
+
Inflate i((unsigned char*)testdata, testdata_size, testdata_length);
|
62
|
+
EXPECT_TRUE(i.decompress());
|
63
|
+
|
64
|
+
const unsigned char f[] = {0,1,2,3,4,5,6,7,8,9};
|
65
|
+
ASSERT_TRUE(memcmp(i.data(), f, 10) == 0);
|
66
|
+
}
|
67
|
+
|
68
|
+
TEST_F(InflateTest, decompress_2)
|
69
|
+
{
|
70
|
+
Inflate i(NULL, testdata_size, testdata_length);
|
71
|
+
ASSERT_FALSE(i.decompress());
|
72
|
+
}
|
73
|
+
|
74
|
+
TEST_F(InflateTest, decompress_3)
|
75
|
+
{
|
76
|
+
Inflate i((unsigned char*)testdata, testdata_size - 1, testdata_length);
|
77
|
+
ASSERT_FALSE(i.decompress());
|
78
|
+
}
|
79
|
+
|
80
|
+
TEST_F(InflateTest, decompress_4)
|
81
|
+
{
|
82
|
+
Inflate i((unsigned char*)testdata, testdata_size, testdata_length - 1);
|
83
|
+
ASSERT_FALSE(i.decompress());
|
84
|
+
}
|