1 : // Copyright 2012 Google Inc. All Rights Reserved.
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 : // http://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 "syzygy/msf/msf_stream.h"
16 :
17 : #include "gtest/gtest.h"
18 :
19 : namespace msf {
20 :
21 : namespace {
22 :
23 : class TestMsfStream : public MsfStream {
24 : public:
25 E : explicit TestMsfStream(size_t length) : MsfStream(length) {}
26 :
27 : // A simple implementation of ReadBytes.
28 i : bool ReadBytesAt(size_t pos, size_t count, void* dest) {
29 i : ADD_FAILURE() << "No implementation here.";
30 i : return false;
31 i : }
32 : };
33 :
34 : struct Foo {
35 : uint32_t i;
36 : double d;
37 : };
38 :
39 : struct Bar {
40 : Foo foo1;
41 : Foo foo2;
42 : };
43 :
44 : } // namespace
45 :
46 E : TEST(MsfStreamTest, Constructor) {
47 E : scoped_refptr<TestMsfStream> stream(new TestMsfStream(5));
48 E : EXPECT_EQ(5, stream->length());
49 :
50 E : scoped_refptr<TestMsfStream> stream2(new TestMsfStream(SIZE_MAX));
51 E : EXPECT_EQ(0, stream2->length());
52 E : }
53 :
54 : } // namespace msf
|