Shaka Packager SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
file_test_util.h
1 // Copyright 2015 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_FILE_FILE_TEST_UTIL_H_
8 #define MEDIA_FILE_FILE_TEST_UTIL_H_
9 
10 #include <gmock/gmock.h>
11 #include <gtest/gtest.h>
12 
13 #include <string>
14 
15 #include "packager/file/file.h"
16 
17 namespace shaka {
18 
19 #define ASSERT_FILE_EQ(file_name, array) \
20  do { \
21  std::string temp_data; \
22  ASSERT_TRUE(File::ReadFileToString((file_name), &temp_data)); \
23  const char* array_ptr = reinterpret_cast<const char*>(array); \
24  ASSERT_EQ(std::string(array_ptr, arraysize(array)), temp_data); \
25  } while (false)
26 
27 #define ASSERT_FILE_STREQ(file_name, str) \
28  do { \
29  std::string temp_data; \
30  ASSERT_TRUE(File::ReadFileToString((file_name), &temp_data)); \
31  ASSERT_EQ(str, temp_data); \
32  } while (false)
33 
34 #define ASSERT_FILE_ENDS_WITH(file_name, array) \
35  do { \
36  std::string temp_data; \
37  ASSERT_TRUE(File::ReadFileToString((file_name), &temp_data)); \
38  EXPECT_THAT(temp_data, \
39  ::testing::EndsWith(std::string( \
40  reinterpret_cast<const char*>(array), sizeof(array)))); \
41  } while (false)
42 
43 } // namespace shaka
44 
45 #endif // MEDIA_FILE_FILE_TEST_UTIL_H_