| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with 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 | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and | 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. | 13 // limitations under the License. |
| 14 | 14 |
| 15 #include "util/file/string_file_writer.h" | 15 #include "util/file/string_file_writer.h" |
| 16 | 16 |
| 17 #include <algorithm> | 17 #include <algorithm> |
| 18 #include <limits> | 18 #include <limits> |
| 19 | 19 |
| 20 #include "gtest/gtest.h" | 20 #include "gtest/gtest.h" |
| 21 | 21 |
| 22 namespace crashpad { |
| 23 namespace test { |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 using namespace crashpad; | |
| 25 | |
| 26 TEST(StringFileWriter, EmptyFile) { | 26 TEST(StringFileWriter, EmptyFile) { |
| 27 StringFileWriter writer; | 27 StringFileWriter writer; |
| 28 EXPECT_TRUE(writer.string().empty()); | 28 EXPECT_TRUE(writer.string().empty()); |
| 29 EXPECT_EQ(0, writer.Seek(0, SEEK_CUR)); | 29 EXPECT_EQ(0, writer.Seek(0, SEEK_CUR)); |
| 30 EXPECT_TRUE(writer.Write("", 0)); | 30 EXPECT_TRUE(writer.Write("", 0)); |
| 31 EXPECT_TRUE(writer.string().empty()); | 31 EXPECT_TRUE(writer.string().empty()); |
| 32 EXPECT_EQ(0, writer.Seek(0, SEEK_CUR)); | 32 EXPECT_EQ(0, writer.Seek(0, SEEK_CUR)); |
| 33 } | 33 } |
| 34 | 34 |
| 35 TEST(StringFileWriter, OneByteFile) { | 35 TEST(StringFileWriter, OneByteFile) { |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 EXPECT_EQ(kMaxOffset, writer.Seek(kMaxOffset, SEEK_SET)); | 369 EXPECT_EQ(kMaxOffset, writer.Seek(kMaxOffset, SEEK_SET)); |
| 370 EXPECT_EQ(kMaxOffset, writer.Seek(0, SEEK_CUR)); | 370 EXPECT_EQ(kMaxOffset, writer.Seek(0, SEEK_CUR)); |
| 371 EXPECT_LT(writer.Seek(1, SEEK_CUR), 0); | 371 EXPECT_LT(writer.Seek(1, SEEK_CUR), 0); |
| 372 | 372 |
| 373 EXPECT_EQ(1, writer.Seek(1, SEEK_SET)); | 373 EXPECT_EQ(1, writer.Seek(1, SEEK_SET)); |
| 374 EXPECT_EQ(1, writer.Seek(0, SEEK_CUR)); | 374 EXPECT_EQ(1, writer.Seek(0, SEEK_CUR)); |
| 375 EXPECT_LT(writer.Seek(kMaxOffset, SEEK_CUR), 0); | 375 EXPECT_LT(writer.Seek(kMaxOffset, SEEK_CUR), 0); |
| 376 } | 376 } |
| 377 | 377 |
| 378 } // namespace | 378 } // namespace |
| 379 } // namespace test |
| 380 } // namespace crashpad |
| OLD | NEW |