DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
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/media/file/file.h"
16 
17 namespace shaka {
18 namespace media {
19 
20 #define ASSERT_FILE_EQ(file_name, array) \
21  do { \
22  std::string temp_data; \
23  ASSERT_TRUE(media::File::ReadFileToString((file_name), &temp_data)); \
24  const char* array_ptr = reinterpret_cast<const char*>(array); \
25  ASSERT_EQ(std::string(array_ptr, arraysize(array)), temp_data); \
26  } while (false)
27 
28 #define ASSERT_FILE_STREQ(file_name, str) \
29  do { \
30  std::string temp_data; \
31  ASSERT_TRUE(media::File::ReadFileToString((file_name), &temp_data)); \
32  ASSERT_EQ(str, temp_data); \
33  } while (false)
34 
35 #define ASSERT_FILE_ENDS_WITH(file_name, array) \
36  do { \
37  std::string temp_data; \
38  ASSERT_TRUE(media::File::ReadFileToString((file_name), &temp_data)); \
39  EXPECT_THAT(temp_data, \
40  ::testing::EndsWith(std::string( \
41  reinterpret_cast<const char*>(array), sizeof(array)))); \
42  } while (false)
43 
44 } // namespace media
45 } // namespace shaka
46 
47 #endif // MEDIA_FILE_FILE_TEST_UTIL_H_