• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2010 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 
5 #include "include/cef_stream.h"
6 #include "include/cef_zip_reader.h"
7 #include "include/wrapper/cef_zip_archive.h"
8 #include "tests/gtest/include/gtest/gtest.h"
9 
10 namespace {
11 
12 unsigned char g_test_zip[] = {
13     0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x7f,
14     0x57, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15     0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61,
16     0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x50, 0x4b, 0x03, 0x04, 0x0a,
17     0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x7f, 0x57, 0x3d, 0xf8, 0x47, 0x0c,
18     0xc6, 0x13, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00,
19     0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76,
20     0x65, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x2e, 0x74, 0x78, 0x74,
21     0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66, 0x20,
22     0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x2e, 0x50, 0x4b, 0x03, 0x04, 0x0a,
23     0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x7f, 0x57, 0x3d, 0x00, 0x00, 0x00,
24     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00,
25     0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76,
26     0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x2f, 0x50,
27     0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x7f, 0x57,
28     0x3d, 0x43, 0xe3, 0x11, 0x5f, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00,
29     0x00, 0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72,
30     0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72,
31     0x20, 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x61, 0x2e, 0x74,
32     0x78, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f,
33     0x66, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x41, 0x2e, 0x50, 0x4b,
34     0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x7f, 0x57, 0x3d,
35     0x80, 0xb0, 0x3c, 0x74, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00,
36     0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63,
37     0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20,
38     0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x62, 0x2e, 0x74, 0x78,
39     0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66,
40     0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x42, 0x2e, 0x50, 0x4b, 0x03,
41     0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x7f, 0x57, 0x3d, 0x00,
42     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
43     0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68,
44     0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31,
45     0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x61, 0x2f, 0x50,
46     0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7c, 0x7f, 0x57,
47     0x3d, 0x15, 0xed, 0x04, 0x2c, 0x15, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00,
48     0x00, 0x2c, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72,
49     0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72,
50     0x20, 0x31, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x61,
51     0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x61, 0x31, 0x2e, 0x74, 0x78,
52     0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x6f, 0x66,
53     0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x41, 0x31, 0x2e, 0x50, 0x4b,
54     0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x7f, 0x57, 0x3d,
55     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56     0x16, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63,
57     0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20,
58     0x32, 0x2f, 0x50, 0x4b, 0x03, 0x04, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
59     0x02, 0x80, 0x57, 0x3d, 0x1a, 0x5d, 0x57, 0x5d, 0x14, 0x00, 0x00, 0x00,
60     0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74,
61     0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c,
62     0x64, 0x65, 0x72, 0x20, 0x32, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x32,
63     0x61, 0x2e, 0x74, 0x78, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
64     0x73, 0x20, 0x6f, 0x66, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x32, 0x41,
65     0x2e, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00,
66     0x00, 0x67, 0x7f, 0x57, 0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
67     0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68     0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74,
69     0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f,
70     0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
71     0x70, 0x7f, 0x57, 0x3d, 0xf8, 0x47, 0x0c, 0xc6, 0x13, 0x00, 0x00, 0x00,
72     0x13, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73     0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x74, 0x65,
74     0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66,
75     0x69, 0x6c, 0x65, 0x20, 0x31, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, 0x01,
76     0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x53, 0x7f, 0x57,
77     0x3d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78     0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
79     0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f,
80     0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64,
81     0x65, 0x72, 0x20, 0x31, 0x2f, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a,
82     0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x7f, 0x57, 0x3d, 0x43, 0xe3, 0x11,
83     0x5f, 0x14, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00,
84     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xa7,
85     0x00, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68,
86     0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31,
87     0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x31, 0x61, 0x2e, 0x74, 0x78, 0x74,
88     0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
89     0x78, 0x7f, 0x57, 0x3d, 0x80, 0xb0, 0x3c, 0x74, 0x14, 0x00, 0x00, 0x00,
90     0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
91     0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x00, 0x00, 0x74, 0x65,
92     0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66,
93     0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x2f, 0x66, 0x69, 0x6c, 0x65,
94     0x20, 0x31, 0x62, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, 0x01, 0x02, 0x14,
95     0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x7f, 0x57, 0x3d, 0x00,
96     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
97     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
98     0x00, 0x4d, 0x01, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72,
99     0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72,
100     0x20, 0x31, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x61,
101     0x2f, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00,
102     0x00, 0x7c, 0x7f, 0x57, 0x3d, 0x15, 0xed, 0x04, 0x2c, 0x15, 0x00, 0x00,
103     0x00, 0x15, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
104     0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x8b, 0x01, 0x00, 0x00, 0x74,
105     0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76, 0x65, 0x2f,
106     0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x31, 0x2f, 0x66, 0x6f, 0x6c,
107     0x64, 0x65, 0x72, 0x20, 0x31, 0x61, 0x2f, 0x66, 0x69, 0x6c, 0x65, 0x20,
108     0x31, 0x61, 0x31, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b, 0x01, 0x02, 0x14,
109     0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x62, 0x7f, 0x57, 0x3d, 0x00,
110     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16,
111     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
112     0x00, 0xea, 0x01, 0x00, 0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72,
113     0x63, 0x68, 0x69, 0x76, 0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72,
114     0x20, 0x32, 0x2f, 0x50, 0x4b, 0x01, 0x02, 0x14, 0x00, 0x0a, 0x00, 0x00,
115     0x00, 0x00, 0x00, 0x02, 0x80, 0x57, 0x3d, 0x1a, 0x5d, 0x57, 0x5d, 0x14,
116     0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00,
117     0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1e, 0x02, 0x00,
118     0x00, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x61, 0x72, 0x63, 0x68, 0x69, 0x76,
119     0x65, 0x2f, 0x66, 0x6f, 0x6c, 0x64, 0x65, 0x72, 0x20, 0x32, 0x2f, 0x66,
120     0x69, 0x6c, 0x65, 0x20, 0x32, 0x61, 0x2e, 0x74, 0x78, 0x74, 0x50, 0x4b,
121     0x05, 0x06, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x09, 0x00, 0x9d, 0x02,
122     0x00, 0x00, 0x71, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00};
123 
124 }  // namespace
125 
126 // Test Zip reading.
TEST(ZipReaderTest,Read)127 TEST(ZipReaderTest, Read) {
128   // Create the stream reader.
129   CefRefPtr<CefStreamReader> stream(
130       CefStreamReader::CreateForData(g_test_zip, sizeof(g_test_zip) - 1));
131   ASSERT_TRUE(stream.get() != nullptr);
132 
133   // Create the Zip reader.
134   CefRefPtr<CefZipReader> reader(CefZipReader::Create(stream));
135   ASSERT_TRUE(reader.get() != nullptr);
136 
137   char buff[25];
138 
139   // Walk through the archive contents.
140   ASSERT_TRUE(reader->MoveToFirstFile());
141   ASSERT_EQ(reader->GetFileName(), "test_archive/");
142   ASSERT_EQ(reader->GetFileSize(), 0);
143 
144   ASSERT_TRUE(reader->MoveToNextFile());
145   ASSERT_EQ(reader->GetFileName(), "test_archive/file 1.txt");
146   ASSERT_EQ(reader->GetFileSize(), 19);
147   ASSERT_TRUE(reader->OpenFile(""));
148   ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 19);
149   ASSERT_TRUE(!strncmp(buff, "Contents of file 1.", 19));
150 
151   ASSERT_TRUE(reader->MoveToNextFile());
152   ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/");
153   ASSERT_EQ(reader->GetFileSize(), 0);
154 
155   ASSERT_TRUE(reader->MoveToNextFile());
156   ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/file 1a.txt");
157   ASSERT_EQ(reader->GetFileSize(), 20);
158   ASSERT_TRUE(reader->OpenFile(""));
159   ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20);
160   ASSERT_TRUE(reader->CloseFile());
161   ASSERT_TRUE(!strncmp(buff, "Contents of file 1A.", 20));
162 
163   ASSERT_TRUE(reader->MoveToNextFile());
164   ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/file 1b.txt");
165   ASSERT_EQ(reader->GetFileSize(), 20);
166   ASSERT_TRUE(reader->OpenFile(""));
167   ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20);
168   ASSERT_TRUE(reader->CloseFile());
169   ASSERT_TRUE(!strncmp(buff, "Contents of file 1B.", 20));
170 
171   ASSERT_TRUE(reader->MoveToNextFile());
172   ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/folder 1a/");
173   ASSERT_EQ(reader->GetFileSize(), 0);
174 
175   ASSERT_TRUE(reader->MoveToNextFile());
176   ASSERT_EQ(reader->GetFileName(),
177             "test_archive/folder 1/folder 1a/file 1a1.txt");
178   ASSERT_EQ(reader->GetFileSize(), 21);
179   ASSERT_TRUE(reader->OpenFile(""));
180   ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 21);
181   ASSERT_TRUE(reader->CloseFile());
182   ASSERT_TRUE(!strncmp(buff, "Contents of file 1A1.", 21));
183 
184   ASSERT_TRUE(reader->MoveToNextFile());
185   ASSERT_EQ(reader->GetFileName(), "test_archive/folder 2/");
186   ASSERT_EQ(reader->GetFileSize(), 0);
187 
188   ASSERT_TRUE(reader->MoveToNextFile());
189   ASSERT_EQ(reader->GetFileName(), "test_archive/folder 2/file 2a.txt");
190   ASSERT_EQ(reader->GetFileSize(), 20);
191   ASSERT_TRUE(reader->OpenFile(""));
192   ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20);
193   ASSERT_TRUE(reader->CloseFile());
194   ASSERT_TRUE(!strncmp(buff, "Contents of file 2A.", 20));
195 
196   ASSERT_FALSE(reader->MoveToNextFile());
197 
198   // Try seeking a particular file
199   ASSERT_TRUE(reader->MoveToFile("TEST_ARCHIVE/FOLDER 1/FILE 1B.TXT", false));
200   ASSERT_EQ(reader->GetFileName(), "test_archive/folder 1/file 1b.txt");
201   ASSERT_EQ(reader->GetFileSize(), 20);
202   ASSERT_TRUE(reader->OpenFile(""));
203   ASSERT_EQ(reader->ReadFile(buff, sizeof(buff)), 20);
204   ASSERT_TRUE(reader->CloseFile());
205   ASSERT_TRUE(!strncmp(buff, "Contents of file 1B.", 20));
206 
207   ASSERT_TRUE(reader->MoveToFile("test_archive/folder 1/file 1b.txt", true));
208   ASSERT_FALSE(reader->MoveToFile("test_archive/folder 1/FILE 1B.txt", true));
209 
210   ASSERT_TRUE(reader->Close());
211 }
212 
213 // Test CefZipArchive object.
TEST(ZipReaderTest,ReadArchive)214 TEST(ZipReaderTest, ReadArchive) {
215   // Create the stream reader.
216   CefRefPtr<CefStreamReader> stream(
217       CefStreamReader::CreateForData(g_test_zip, sizeof(g_test_zip) - 1));
218   ASSERT_TRUE(stream.get() != nullptr);
219 
220   // Create the Zip archive object.
221   CefRefPtr<CefZipArchive> archive(new CefZipArchive());
222 
223   ASSERT_EQ(archive->Load(stream, CefString(), false), (size_t)5);
224 
225   ASSERT_TRUE(archive->HasFile("test_archive/file 1.txt"));
226   ASSERT_TRUE(archive->HasFile("test_archive/folder 1/file 1a.txt"));
227   ASSERT_TRUE(archive->HasFile("test_archive/FOLDER 1/file 1b.txt"));
228   ASSERT_TRUE(archive->HasFile("test_archive/folder 1/folder 1a/file 1a1.txt"));
229   ASSERT_TRUE(archive->HasFile("test_archive/folder 2/file 2a.txt"));
230 
231   // Test content retrieval.
232   CefRefPtr<CefZipArchive::File> file;
233   file = archive->GetFile("test_archive/folder 2/file 2a.txt");
234   ASSERT_TRUE(file.get());
235 
236   ASSERT_EQ(file->GetDataSize(), (size_t)20);
237   ASSERT_TRUE(!strncmp(reinterpret_cast<const char*>(file->GetData()),
238                        "Contents of file 2A.", 20));
239 
240   // Test stream reading.
241   CefRefPtr<CefStreamReader> reader(file->GetStreamReader());
242   ASSERT_TRUE(reader.get());
243 
244   char buff[8];
245   ASSERT_EQ(reader->Read(buff, 1, 8), (size_t)8);
246   ASSERT_TRUE(!strncmp(buff, "Contents", 8));
247   ASSERT_EQ(reader->Read(buff, 1, 8), (size_t)8);
248   ASSERT_TRUE(!strncmp(buff, " of file", 8));
249   ASSERT_EQ(reader->Read(buff, 1, 8), (size_t)4);
250   ASSERT_TRUE(!strncmp(buff, " 2A.", 4));
251   ASSERT_TRUE(reader->Eof());
252 }
253