1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "modules/audio_processing/transient/file_utils.h"
12
13 #include <string.h>
14
15 #include <memory>
16 #include <string>
17 #include <vector>
18
19 #include "rtc_base/system/file_wrapper.h"
20 #include "test/gtest.h"
21 #include "test/testsupport/file_utils.h"
22
23 namespace webrtc {
24
25 static const uint8_t kPiBytesf[4] = {0xDB, 0x0F, 0x49, 0x40};
26 static const uint8_t kEBytesf[4] = {0x54, 0xF8, 0x2D, 0x40};
27 static const uint8_t kAvogadroBytesf[4] = {0x2F, 0x0C, 0xFF, 0x66};
28
29 static const uint8_t kPiBytes[8] = {0x18, 0x2D, 0x44, 0x54,
30 0xFB, 0x21, 0x09, 0x40};
31 static const uint8_t kEBytes[8] = {0x69, 0x57, 0x14, 0x8B,
32 0x0A, 0xBF, 0x05, 0x40};
33 static const uint8_t kAvogadroBytes[8] = {0xF4, 0xBC, 0xA8, 0xDF,
34 0x85, 0xE1, 0xDF, 0x44};
35
36 static const double kPi = 3.14159265358979323846;
37 static const double kE = 2.71828182845904523536;
38 static const double kAvogadro = 602214100000000000000000.0;
39
40 class TransientFileUtilsTest : public ::testing::Test {
41 protected:
TransientFileUtilsTest()42 TransientFileUtilsTest()
43 : kTestFileName(
44 test::ResourcePath("audio_processing/transient/double-utils",
45 "dat")),
46 kTestFileNamef(
47 test::ResourcePath("audio_processing/transient/float-utils",
48 "dat")) {}
49
~TransientFileUtilsTest()50 ~TransientFileUtilsTest() override { CleanupTempFiles(); }
51
CreateTempFilename(const std::string & dir,const std::string & prefix)52 std::string CreateTempFilename(const std::string& dir,
53 const std::string& prefix) {
54 std::string filename = test::TempFilename(dir, prefix);
55 temp_filenames_.push_back(filename);
56 return filename;
57 }
58
CleanupTempFiles()59 void CleanupTempFiles() {
60 for (const std::string& filename : temp_filenames_) {
61 remove(filename.c_str());
62 }
63 temp_filenames_.clear();
64 }
65
66 // This file (used in some tests) contains binary data. The data correspond to
67 // the double representation of the constants: Pi, E, and the Avogadro's
68 // Number;
69 // appended in that order.
70 const std::string kTestFileName;
71
72 // This file (used in some tests) contains binary data. The data correspond to
73 // the float representation of the constants: Pi, E, and the Avogadro's
74 // Number;
75 // appended in that order.
76 const std::string kTestFileNamef;
77
78 // List of temporary filenames created by CreateTempFilename.
79 std::vector<std::string> temp_filenames_;
80 };
81
82 #if defined(WEBRTC_IOS)
83 #define MAYBE_ConvertByteArrayToFloat DISABLED_ConvertByteArrayToFloat
84 #else
85 #define MAYBE_ConvertByteArrayToFloat ConvertByteArrayToFloat
86 #endif
TEST_F(TransientFileUtilsTest,MAYBE_ConvertByteArrayToFloat)87 TEST_F(TransientFileUtilsTest, MAYBE_ConvertByteArrayToFloat) {
88 float value = 0.0;
89
90 EXPECT_EQ(0, ConvertByteArrayToFloat(kPiBytesf, &value));
91 EXPECT_FLOAT_EQ(kPi, value);
92
93 EXPECT_EQ(0, ConvertByteArrayToFloat(kEBytesf, &value));
94 EXPECT_FLOAT_EQ(kE, value);
95
96 EXPECT_EQ(0, ConvertByteArrayToFloat(kAvogadroBytesf, &value));
97 EXPECT_FLOAT_EQ(kAvogadro, value);
98 }
99
100 #if defined(WEBRTC_IOS)
101 #define MAYBE_ConvertByteArrayToDouble DISABLED_ConvertByteArrayToDouble
102 #else
103 #define MAYBE_ConvertByteArrayToDouble ConvertByteArrayToDouble
104 #endif
TEST_F(TransientFileUtilsTest,MAYBE_ConvertByteArrayToDouble)105 TEST_F(TransientFileUtilsTest, MAYBE_ConvertByteArrayToDouble) {
106 double value = 0.0;
107
108 EXPECT_EQ(0, ConvertByteArrayToDouble(kPiBytes, &value));
109 EXPECT_DOUBLE_EQ(kPi, value);
110
111 EXPECT_EQ(0, ConvertByteArrayToDouble(kEBytes, &value));
112 EXPECT_DOUBLE_EQ(kE, value);
113
114 EXPECT_EQ(0, ConvertByteArrayToDouble(kAvogadroBytes, &value));
115 EXPECT_DOUBLE_EQ(kAvogadro, value);
116 }
117
118 #if defined(WEBRTC_IOS)
119 #define MAYBE_ConvertFloatToByteArray DISABLED_ConvertFloatToByteArray
120 #else
121 #define MAYBE_ConvertFloatToByteArray ConvertFloatToByteArray
122 #endif
TEST_F(TransientFileUtilsTest,MAYBE_ConvertFloatToByteArray)123 TEST_F(TransientFileUtilsTest, MAYBE_ConvertFloatToByteArray) {
124 std::unique_ptr<uint8_t[]> bytes(new uint8_t[4]);
125
126 EXPECT_EQ(0, ConvertFloatToByteArray(kPi, bytes.get()));
127 EXPECT_EQ(0, memcmp(bytes.get(), kPiBytesf, 4));
128
129 EXPECT_EQ(0, ConvertFloatToByteArray(kE, bytes.get()));
130 EXPECT_EQ(0, memcmp(bytes.get(), kEBytesf, 4));
131
132 EXPECT_EQ(0, ConvertFloatToByteArray(kAvogadro, bytes.get()));
133 EXPECT_EQ(0, memcmp(bytes.get(), kAvogadroBytesf, 4));
134 }
135
136 #if defined(WEBRTC_IOS)
137 #define MAYBE_ConvertDoubleToByteArray DISABLED_ConvertDoubleToByteArray
138 #else
139 #define MAYBE_ConvertDoubleToByteArray ConvertDoubleToByteArray
140 #endif
TEST_F(TransientFileUtilsTest,MAYBE_ConvertDoubleToByteArray)141 TEST_F(TransientFileUtilsTest, MAYBE_ConvertDoubleToByteArray) {
142 std::unique_ptr<uint8_t[]> bytes(new uint8_t[8]);
143
144 EXPECT_EQ(0, ConvertDoubleToByteArray(kPi, bytes.get()));
145 EXPECT_EQ(0, memcmp(bytes.get(), kPiBytes, 8));
146
147 EXPECT_EQ(0, ConvertDoubleToByteArray(kE, bytes.get()));
148 EXPECT_EQ(0, memcmp(bytes.get(), kEBytes, 8));
149
150 EXPECT_EQ(0, ConvertDoubleToByteArray(kAvogadro, bytes.get()));
151 EXPECT_EQ(0, memcmp(bytes.get(), kAvogadroBytes, 8));
152 }
153
154 #if defined(WEBRTC_IOS)
155 #define MAYBE_ReadInt16BufferFromFile DISABLED_ReadInt16BufferFromFile
156 #else
157 #define MAYBE_ReadInt16BufferFromFile ReadInt16BufferFromFile
158 #endif
TEST_F(TransientFileUtilsTest,MAYBE_ReadInt16BufferFromFile)159 TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16BufferFromFile) {
160 std::string test_filename = kTestFileName;
161
162 FileWrapper file = FileWrapper::OpenReadOnly(test_filename.c_str());
163 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
164 << kTestFileName.c_str();
165
166 const size_t kBufferLength = 12;
167 std::unique_ptr<int16_t[]> buffer(new int16_t[kBufferLength]);
168
169 EXPECT_EQ(kBufferLength,
170 ReadInt16BufferFromFile(&file, kBufferLength, buffer.get()));
171 EXPECT_EQ(22377, buffer[4]);
172 EXPECT_EQ(16389, buffer[7]);
173 EXPECT_EQ(17631, buffer[kBufferLength - 1]);
174
175 file.Rewind();
176
177 // The next test is for checking the case where there are not as much data as
178 // needed in the file, but reads to the end, and it returns the number of
179 // int16s read.
180 const size_t kBufferLenghtLargerThanFile = kBufferLength * 2;
181 buffer.reset(new int16_t[kBufferLenghtLargerThanFile]);
182 EXPECT_EQ(kBufferLength,
183 ReadInt16BufferFromFile(&file, kBufferLenghtLargerThanFile,
184 buffer.get()));
185 EXPECT_EQ(11544, buffer[0]);
186 EXPECT_EQ(22377, buffer[4]);
187 EXPECT_EQ(16389, buffer[7]);
188 EXPECT_EQ(17631, buffer[kBufferLength - 1]);
189 }
190
191 #if defined(WEBRTC_IOS)
192 #define MAYBE_ReadInt16FromFileToFloatBuffer \
193 DISABLED_ReadInt16FromFileToFloatBuffer
194 #else
195 #define MAYBE_ReadInt16FromFileToFloatBuffer ReadInt16FromFileToFloatBuffer
196 #endif
TEST_F(TransientFileUtilsTest,MAYBE_ReadInt16FromFileToFloatBuffer)197 TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToFloatBuffer) {
198 std::string test_filename = kTestFileName;
199
200 FileWrapper file = FileWrapper::OpenReadOnly(test_filename.c_str());
201 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
202 << kTestFileName.c_str();
203
204 const size_t kBufferLength = 12;
205 std::unique_ptr<float[]> buffer(new float[kBufferLength]);
206
207 EXPECT_EQ(kBufferLength,
208 ReadInt16FromFileToFloatBuffer(&file, kBufferLength, buffer.get()));
209
210 EXPECT_DOUBLE_EQ(11544, buffer[0]);
211 EXPECT_DOUBLE_EQ(22377, buffer[4]);
212 EXPECT_DOUBLE_EQ(16389, buffer[7]);
213 EXPECT_DOUBLE_EQ(17631, buffer[kBufferLength - 1]);
214
215 file.Rewind();
216
217 // The next test is for checking the case where there are not as much data as
218 // needed in the file, but reads to the end, and it returns the number of
219 // int16s read.
220 const size_t kBufferLenghtLargerThanFile = kBufferLength * 2;
221 buffer.reset(new float[kBufferLenghtLargerThanFile]);
222 EXPECT_EQ(kBufferLength,
223 ReadInt16FromFileToFloatBuffer(&file, kBufferLenghtLargerThanFile,
224 buffer.get()));
225 EXPECT_DOUBLE_EQ(11544, buffer[0]);
226 EXPECT_DOUBLE_EQ(22377, buffer[4]);
227 EXPECT_DOUBLE_EQ(16389, buffer[7]);
228 EXPECT_DOUBLE_EQ(17631, buffer[kBufferLength - 1]);
229 }
230
231 #if defined(WEBRTC_IOS)
232 #define MAYBE_ReadInt16FromFileToDoubleBuffer \
233 DISABLED_ReadInt16FromFileToDoubleBuffer
234 #else
235 #define MAYBE_ReadInt16FromFileToDoubleBuffer ReadInt16FromFileToDoubleBuffer
236 #endif
TEST_F(TransientFileUtilsTest,MAYBE_ReadInt16FromFileToDoubleBuffer)237 TEST_F(TransientFileUtilsTest, MAYBE_ReadInt16FromFileToDoubleBuffer) {
238 std::string test_filename = kTestFileName;
239
240 FileWrapper file = FileWrapper::OpenReadOnly(test_filename.c_str());
241 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
242 << kTestFileName.c_str();
243
244 const size_t kBufferLength = 12;
245 std::unique_ptr<double[]> buffer(new double[kBufferLength]);
246
247 EXPECT_EQ(kBufferLength, ReadInt16FromFileToDoubleBuffer(&file, kBufferLength,
248 buffer.get()));
249 EXPECT_DOUBLE_EQ(11544, buffer[0]);
250 EXPECT_DOUBLE_EQ(22377, buffer[4]);
251 EXPECT_DOUBLE_EQ(16389, buffer[7]);
252 EXPECT_DOUBLE_EQ(17631, buffer[kBufferLength - 1]);
253
254 file.Rewind();
255
256 // The next test is for checking the case where there are not as much data as
257 // needed in the file, but reads to the end, and it returns the number of
258 // int16s read.
259 const size_t kBufferLenghtLargerThanFile = kBufferLength * 2;
260 buffer.reset(new double[kBufferLenghtLargerThanFile]);
261 EXPECT_EQ(kBufferLength,
262 ReadInt16FromFileToDoubleBuffer(&file, kBufferLenghtLargerThanFile,
263 buffer.get()));
264 EXPECT_DOUBLE_EQ(11544, buffer[0]);
265 EXPECT_DOUBLE_EQ(22377, buffer[4]);
266 EXPECT_DOUBLE_EQ(16389, buffer[7]);
267 EXPECT_DOUBLE_EQ(17631, buffer[kBufferLength - 1]);
268 }
269
270 #if defined(WEBRTC_IOS)
271 #define MAYBE_ReadFloatBufferFromFile DISABLED_ReadFloatBufferFromFile
272 #else
273 #define MAYBE_ReadFloatBufferFromFile ReadFloatBufferFromFile
274 #endif
TEST_F(TransientFileUtilsTest,MAYBE_ReadFloatBufferFromFile)275 TEST_F(TransientFileUtilsTest, MAYBE_ReadFloatBufferFromFile) {
276 std::string test_filename = kTestFileNamef;
277
278 FileWrapper file = FileWrapper::OpenReadOnly(test_filename.c_str());
279 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
280 << kTestFileNamef.c_str();
281
282 const size_t kBufferLength = 3;
283 std::unique_ptr<float[]> buffer(new float[kBufferLength]);
284
285 EXPECT_EQ(kBufferLength,
286 ReadFloatBufferFromFile(&file, kBufferLength, buffer.get()));
287 EXPECT_FLOAT_EQ(kPi, buffer[0]);
288 EXPECT_FLOAT_EQ(kE, buffer[1]);
289 EXPECT_FLOAT_EQ(kAvogadro, buffer[2]);
290
291 file.Rewind();
292
293 // The next test is for checking the case where there are not as much data as
294 // needed in the file, but reads to the end, and it returns the number of
295 // doubles read.
296 const size_t kBufferLenghtLargerThanFile = kBufferLength * 2;
297 buffer.reset(new float[kBufferLenghtLargerThanFile]);
298 EXPECT_EQ(kBufferLength,
299 ReadFloatBufferFromFile(&file, kBufferLenghtLargerThanFile,
300 buffer.get()));
301 EXPECT_FLOAT_EQ(kPi, buffer[0]);
302 EXPECT_FLOAT_EQ(kE, buffer[1]);
303 EXPECT_FLOAT_EQ(kAvogadro, buffer[2]);
304 }
305
306 #if defined(WEBRTC_IOS)
307 #define MAYBE_ReadDoubleBufferFromFile DISABLED_ReadDoubleBufferFromFile
308 #else
309 #define MAYBE_ReadDoubleBufferFromFile ReadDoubleBufferFromFile
310 #endif
TEST_F(TransientFileUtilsTest,MAYBE_ReadDoubleBufferFromFile)311 TEST_F(TransientFileUtilsTest, MAYBE_ReadDoubleBufferFromFile) {
312 std::string test_filename = kTestFileName;
313
314 FileWrapper file = FileWrapper::OpenReadOnly(test_filename.c_str());
315 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
316 << kTestFileName.c_str();
317
318 const size_t kBufferLength = 3;
319 std::unique_ptr<double[]> buffer(new double[kBufferLength]);
320
321 EXPECT_EQ(kBufferLength,
322 ReadDoubleBufferFromFile(&file, kBufferLength, buffer.get()));
323 EXPECT_DOUBLE_EQ(kPi, buffer[0]);
324 EXPECT_DOUBLE_EQ(kE, buffer[1]);
325 EXPECT_DOUBLE_EQ(kAvogadro, buffer[2]);
326
327 file.Rewind();
328
329 // The next test is for checking the case where there are not as much data as
330 // needed in the file, but reads to the end, and it returns the number of
331 // doubles read.
332 const size_t kBufferLenghtLargerThanFile = kBufferLength * 2;
333 buffer.reset(new double[kBufferLenghtLargerThanFile]);
334 EXPECT_EQ(kBufferLength,
335 ReadDoubleBufferFromFile(&file, kBufferLenghtLargerThanFile,
336 buffer.get()));
337 EXPECT_DOUBLE_EQ(kPi, buffer[0]);
338 EXPECT_DOUBLE_EQ(kE, buffer[1]);
339 EXPECT_DOUBLE_EQ(kAvogadro, buffer[2]);
340 }
341
342 #if defined(WEBRTC_IOS)
343 #define MAYBE_WriteInt16BufferToFile DISABLED_WriteInt16BufferToFile
344 #else
345 #define MAYBE_WriteInt16BufferToFile WriteInt16BufferToFile
346 #endif
TEST_F(TransientFileUtilsTest,MAYBE_WriteInt16BufferToFile)347 TEST_F(TransientFileUtilsTest, MAYBE_WriteInt16BufferToFile) {
348 std::string kOutFileName =
349 CreateTempFilename(test::OutputPath(), "utils_test");
350
351 FileWrapper file = FileWrapper::OpenWriteOnly(kOutFileName.c_str());
352 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
353 << kOutFileName.c_str();
354
355 const size_t kBufferLength = 3;
356 std::unique_ptr<int16_t[]> written_buffer(new int16_t[kBufferLength]);
357 std::unique_ptr<int16_t[]> read_buffer(new int16_t[kBufferLength]);
358
359 written_buffer[0] = 1;
360 written_buffer[1] = 2;
361 written_buffer[2] = 3;
362
363 EXPECT_EQ(kBufferLength,
364 WriteInt16BufferToFile(&file, kBufferLength, written_buffer.get()));
365
366 file.Close();
367
368 file = FileWrapper::OpenReadOnly(kOutFileName.c_str());
369 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
370 << kOutFileName.c_str();
371
372 EXPECT_EQ(kBufferLength,
373 ReadInt16BufferFromFile(&file, kBufferLength, read_buffer.get()));
374 EXPECT_EQ(0, memcmp(written_buffer.get(), read_buffer.get(),
375 kBufferLength * sizeof(written_buffer[0])));
376 }
377
378 #if defined(WEBRTC_IOS)
379 #define MAYBE_WriteFloatBufferToFile DISABLED_WriteFloatBufferToFile
380 #else
381 #define MAYBE_WriteFloatBufferToFile WriteFloatBufferToFile
382 #endif
TEST_F(TransientFileUtilsTest,MAYBE_WriteFloatBufferToFile)383 TEST_F(TransientFileUtilsTest, MAYBE_WriteFloatBufferToFile) {
384 std::string kOutFileName =
385 CreateTempFilename(test::OutputPath(), "utils_test");
386
387 FileWrapper file = FileWrapper::OpenWriteOnly(kOutFileName.c_str());
388 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
389 << kOutFileName.c_str();
390
391 const size_t kBufferLength = 3;
392 std::unique_ptr<float[]> written_buffer(new float[kBufferLength]);
393 std::unique_ptr<float[]> read_buffer(new float[kBufferLength]);
394
395 written_buffer[0] = static_cast<float>(kPi);
396 written_buffer[1] = static_cast<float>(kE);
397 written_buffer[2] = static_cast<float>(kAvogadro);
398
399 EXPECT_EQ(kBufferLength,
400 WriteFloatBufferToFile(&file, kBufferLength, written_buffer.get()));
401
402 file.Close();
403
404 file = FileWrapper::OpenReadOnly(kOutFileName.c_str());
405 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
406 << kOutFileName.c_str();
407
408 EXPECT_EQ(kBufferLength,
409 ReadFloatBufferFromFile(&file, kBufferLength, read_buffer.get()));
410 EXPECT_EQ(0, memcmp(written_buffer.get(), read_buffer.get(),
411 kBufferLength * sizeof(written_buffer[0])));
412 }
413
414 #if defined(WEBRTC_IOS)
415 #define MAYBE_WriteDoubleBufferToFile DISABLED_WriteDoubleBufferToFile
416 #else
417 #define MAYBE_WriteDoubleBufferToFile WriteDoubleBufferToFile
418 #endif
TEST_F(TransientFileUtilsTest,MAYBE_WriteDoubleBufferToFile)419 TEST_F(TransientFileUtilsTest, MAYBE_WriteDoubleBufferToFile) {
420 std::string kOutFileName =
421 CreateTempFilename(test::OutputPath(), "utils_test");
422
423 FileWrapper file = FileWrapper::OpenWriteOnly(kOutFileName.c_str());
424 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
425 << kOutFileName.c_str();
426
427 const size_t kBufferLength = 3;
428 std::unique_ptr<double[]> written_buffer(new double[kBufferLength]);
429 std::unique_ptr<double[]> read_buffer(new double[kBufferLength]);
430
431 written_buffer[0] = kPi;
432 written_buffer[1] = kE;
433 written_buffer[2] = kAvogadro;
434
435 EXPECT_EQ(kBufferLength, WriteDoubleBufferToFile(&file, kBufferLength,
436 written_buffer.get()));
437
438 file.Close();
439
440 file = FileWrapper::OpenReadOnly(kOutFileName.c_str());
441 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
442 << kOutFileName.c_str();
443
444 EXPECT_EQ(kBufferLength,
445 ReadDoubleBufferFromFile(&file, kBufferLength, read_buffer.get()));
446 EXPECT_EQ(0, memcmp(written_buffer.get(), read_buffer.get(),
447 kBufferLength * sizeof(written_buffer[0])));
448 }
449
450 #if defined(WEBRTC_IOS)
451 #define MAYBE_ExpectedErrorReturnValues DISABLED_ExpectedErrorReturnValues
452 #else
453 #define MAYBE_ExpectedErrorReturnValues ExpectedErrorReturnValues
454 #endif
TEST_F(TransientFileUtilsTest,MAYBE_ExpectedErrorReturnValues)455 TEST_F(TransientFileUtilsTest, MAYBE_ExpectedErrorReturnValues) {
456 std::string test_filename = kTestFileName;
457
458 double value;
459 std::unique_ptr<int16_t[]> int16_buffer(new int16_t[1]);
460 std::unique_ptr<double[]> double_buffer(new double[1]);
461 FileWrapper file;
462
463 EXPECT_EQ(-1, ConvertByteArrayToDouble(NULL, &value));
464 EXPECT_EQ(-1, ConvertByteArrayToDouble(kPiBytes, NULL));
465
466 EXPECT_EQ(-1, ConvertDoubleToByteArray(kPi, NULL));
467
468 // Tests with file not opened.
469 EXPECT_EQ(0u, ReadInt16BufferFromFile(&file, 1, int16_buffer.get()));
470 EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(&file, 1, double_buffer.get()));
471 EXPECT_EQ(0u, ReadDoubleBufferFromFile(&file, 1, double_buffer.get()));
472 EXPECT_EQ(0u, WriteInt16BufferToFile(&file, 1, int16_buffer.get()));
473 EXPECT_EQ(0u, WriteDoubleBufferToFile(&file, 1, double_buffer.get()));
474
475 file = FileWrapper::OpenReadOnly(test_filename.c_str());
476 ASSERT_TRUE(file.is_open()) << "File could not be opened:\n"
477 << kTestFileName.c_str();
478
479 EXPECT_EQ(0u, ReadInt16BufferFromFile(NULL, 1, int16_buffer.get()));
480 EXPECT_EQ(0u, ReadInt16BufferFromFile(&file, 1, NULL));
481 EXPECT_EQ(0u, ReadInt16BufferFromFile(&file, 0, int16_buffer.get()));
482
483 EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(NULL, 1, double_buffer.get()));
484 EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(&file, 1, NULL));
485 EXPECT_EQ(0u, ReadInt16FromFileToDoubleBuffer(&file, 0, double_buffer.get()));
486
487 EXPECT_EQ(0u, ReadDoubleBufferFromFile(NULL, 1, double_buffer.get()));
488 EXPECT_EQ(0u, ReadDoubleBufferFromFile(&file, 1, NULL));
489 EXPECT_EQ(0u, ReadDoubleBufferFromFile(&file, 0, double_buffer.get()));
490
491 EXPECT_EQ(0u, WriteInt16BufferToFile(NULL, 1, int16_buffer.get()));
492 EXPECT_EQ(0u, WriteInt16BufferToFile(&file, 1, NULL));
493 EXPECT_EQ(0u, WriteInt16BufferToFile(&file, 0, int16_buffer.get()));
494
495 EXPECT_EQ(0u, WriteDoubleBufferToFile(NULL, 1, double_buffer.get()));
496 EXPECT_EQ(0u, WriteDoubleBufferToFile(&file, 1, NULL));
497 EXPECT_EQ(0u, WriteDoubleBufferToFile(&file, 0, double_buffer.get()));
498 }
499
500 } // namespace webrtc
501