| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stdio.h> | 5 #include <stdio.h> |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 bool ReadTestCase(const std::string& test, | 141 bool ReadTestCase(const std::string& test, |
| 142 Message* message, | 142 Message* message, |
| 143 std::string* expected) { | 143 std::string* expected) { |
| 144 std::vector<uint8_t> data; | 144 std::vector<uint8_t> data; |
| 145 size_t num_handles; | 145 size_t num_handles; |
| 146 if (!ReadAndParseDataFile(GetPath(test, ".data"), &data, &num_handles) || | 146 if (!ReadAndParseDataFile(GetPath(test, ".data"), &data, &num_handles) || |
| 147 !ReadResultFile(GetPath(test, ".expected"), expected)) { | 147 !ReadResultFile(GetPath(test, ".expected"), expected)) { |
| 148 return false; | 148 return false; |
| 149 } | 149 } |
| 150 | 150 |
| 151 message->AllocUninitializedData(static_cast<uint32_t>(data.size())); | 151 message->Initialize(static_cast<uint32_t>(data.size()), |
| 152 false /* zero_initialized */); |
| 152 if (!data.empty()) | 153 if (!data.empty()) |
| 153 memcpy(message->mutable_data(), &data[0], data.size()); | 154 memcpy(message->buffer()->Allocate(data.size()), &data[0], data.size()); |
| 154 message->mutable_handles()->resize(num_handles); | 155 message->mutable_handles()->resize(num_handles); |
| 155 | 156 |
| 156 return true; | 157 return true; |
| 157 } | 158 } |
| 158 | 159 |
| 159 void RunValidationTests(const std::string& prefix, | 160 void RunValidationTests(const std::string& prefix, |
| 160 MessageReceiver* test_message_receiver) { | 161 MessageReceiver* test_message_receiver) { |
| 161 std::vector<std::string> names = | 162 std::vector<std::string> names = |
| 162 EnumerateSourceRootRelativeDirectory(GetPath("", "")); | 163 EnumerateSourceRootRelativeDirectory(GetPath("", "")); |
| 163 std::vector<std::string> tests = GetMatchingTests(names, prefix); | 164 std::vector<std::string> tests = GetMatchingTests(names, prefix); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 static_cast<StructWithEnum::EnumWithin>(2))); | 484 static_cast<StructWithEnum::EnumWithin>(2))); |
| 484 EXPECT_TRUE(StructWithEnum::EnumWithin_IsValidValue( | 485 EXPECT_TRUE(StructWithEnum::EnumWithin_IsValidValue( |
| 485 static_cast<StructWithEnum::EnumWithin>(3))); | 486 static_cast<StructWithEnum::EnumWithin>(3))); |
| 486 EXPECT_FALSE(StructWithEnum::EnumWithin_IsValidValue( | 487 EXPECT_FALSE(StructWithEnum::EnumWithin_IsValidValue( |
| 487 static_cast<StructWithEnum::EnumWithin>(4))); | 488 static_cast<StructWithEnum::EnumWithin>(4))); |
| 488 } | 489 } |
| 489 | 490 |
| 490 } // namespace | 491 } // namespace |
| 491 } // namespace test | 492 } // namespace test |
| 492 } // namespace mojo | 493 } // namespace mojo |
| OLD | NEW |