Shaka Packager SDK
Loading...
Searching...
No Matches
packager
file
file_test_util.h
1
// Copyright 2015 Google LLC. 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 <string>
11
12
#include <gmock/gmock.h>
13
#include <gtest/gtest.h>
14
15
16
namespace
shaka
{
17
18
#define ASSERT_FILE_EQ(file_name, array) \
19
do { \
20
std::string temp_data; \
21
ASSERT_TRUE(File::ReadFileToString((file_name), &temp_data)); \
22
const char* array_ptr = reinterpret_cast<const char*>(array); \
23
ASSERT_EQ(std::string(array_ptr, std::size(array)), temp_data); \
24
} while (false)
25
26
#define ASSERT_FILE_STREQ(file_name, str) \
27
do { \
28
std::string temp_data; \
29
ASSERT_TRUE(File::ReadFileToString((file_name), &temp_data)); \
30
ASSERT_EQ(str, temp_data); \
31
} while (false)
32
33
#define ASSERT_FILE_ENDS_WITH(file_name, array) \
34
do { \
35
std::string temp_data; \
36
ASSERT_TRUE(File::ReadFileToString((file_name), &temp_data)); \
37
EXPECT_THAT(temp_data, \
38
::testing::EndsWith(std::string( \
39
reinterpret_cast<const char*>(array), sizeof(array)))); \
40
} while (false)
41
42
// Generate a unique filename.
43
std::string generate_unique_temp_path();
44
void
delete_file(
const
std::string& path);
45
46
// A temporary file that is removed from the filesystem when the object is
47
// destroyed. Useful in tests that use ASSERT to avoid leaving behind temp
48
// files.
49
class
TempFile
{
50
public
:
51
TempFile
();
52
~TempFile
();
53
54
const
std::string& path()
const
{
return
path_; }
55
56
private
:
57
std::string path_;
58
};
59
60
}
// namespace shaka
61
62
#endif
// MEDIA_FILE_FILE_TEST_UTIL_H_
shaka::TempFile
Definition
file_test_util.h:49
shaka
All the methods that are virtual are virtual for mocking.
Definition
cpix_encryption_flags.cc:51
Generated on Mon Jul 27 2026 18:29:59 for Shaka Packager SDK by
1.9.8