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