OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
| 5 #include <stddef.h> |
| 6 |
5 #include "chromeos/binder/buffer_reader.h" | 7 #include "chromeos/binder/buffer_reader.h" |
6 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
7 | 9 |
8 namespace binder { | 10 namespace binder { |
9 | 11 |
10 TEST(BinderBufferReaderTest, Read) { | 12 TEST(BinderBufferReaderTest, Read) { |
11 // Prepare data. | 13 // Prepare data. |
12 const size_t N = 4; | 14 const size_t N = 4; |
13 int data[N]; | 15 int data[N]; |
14 for (size_t i = 0; i < N; ++i) { | 16 for (size_t i = 0; i < N; ++i) { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 int value = 0; | 48 int value = 0; |
47 EXPECT_TRUE(reader.Read(&value, sizeof(value))); | 49 EXPECT_TRUE(reader.Read(&value, sizeof(value))); |
48 EXPECT_EQ(data[i], value); | 50 EXPECT_EQ(data[i], value); |
49 } | 51 } |
50 EXPECT_FALSE(reader.HasMoreData()); | 52 EXPECT_FALSE(reader.HasMoreData()); |
51 // No longer able to skip. | 53 // No longer able to skip. |
52 EXPECT_FALSE(reader.Skip(sizeof(data[0]))); | 54 EXPECT_FALSE(reader.Skip(sizeof(data[0]))); |
53 } | 55 } |
54 | 56 |
55 } // namespace binder | 57 } // namespace binder |
OLD | NEW |