1 // Copyright 2019 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include <string>
16
17 #include "gmock/gmock.h"
18 #include "gtest/gtest.h"
19 #include "sandboxed_api/testing.h"
20 #include "sandboxed_api/tools/filewrapper/filewrapper_embedded.h"
21 #include "sandboxed_api/util/file_helpers.h"
22 #include "sandboxed_api/util/status_matchers.h"
23
24 namespace sapi {
25 namespace {
26
27 using ::sapi::GetTestSourcePath;
28 using ::sapi::IsOk;
29 using ::testing::Eq;
30 using ::testing::IsNull;
31 using ::testing::StrEq;
32
TEST(FilewrapperTest,BasicFunctionality)33 TEST(FilewrapperTest, BasicFunctionality) {
34 const FileToc* toc = filewrapper_embedded_create();
35
36 EXPECT_THAT(toc->name, StrEq("filewrapper_embedded.bin"));
37 EXPECT_THAT(toc->size, Eq(256));
38
39 std::string contents;
40 ASSERT_THAT(file::GetContents(
41 GetTestSourcePath(
42 "tools/filewrapper/testdata/filewrapper_embedded.bin"),
43 &contents, file::Defaults()),
44 IsOk());
45 EXPECT_THAT(std::string(toc->data, toc->size), StrEq(contents));
46
47 ++toc;
48 EXPECT_THAT(toc->name, IsNull());
49 }
50
51 } // namespace
52 } // namespace sapi
53