| 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 "mojo/public/cpp/bindings/tests/validation_test_input_parser.h" | 5 #include "mojo/public/cpp/bindings/tests/validation_test_input_parser.h" |
| 6 | 6 |
| 7 #include <assert.h> | 7 #include <assert.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 size_t prefix_length) { | 377 size_t prefix_length) { |
| 378 if (static_cast<size_t>(range.second - range.first) < prefix_length) | 378 if (static_cast<size_t>(range.second - range.first) < prefix_length) |
| 379 return false; | 379 return false; |
| 380 | 380 |
| 381 return memcmp(range.first, prefix, prefix_length) == 0; | 381 return memcmp(range.first, prefix, prefix_length) == 0; |
| 382 } | 382 } |
| 383 | 383 |
| 384 bool ValidationTestInputParser::ConvertToUnsignedInteger( | 384 bool ValidationTestInputParser::ConvertToUnsignedInteger( |
| 385 const std::string& value_string, | 385 const std::string& value_string, |
| 386 unsigned long long int* value) { | 386 unsigned long long int* value) { |
| 387 const char* format = NULL; | 387 const char* format = nullptr; |
| 388 if (value_string.find_first_of("xX") != std::string::npos) | 388 if (value_string.find_first_of("xX") != std::string::npos) |
| 389 format = "%llx"; | 389 format = "%llx"; |
| 390 else | 390 else |
| 391 format = "%llu"; | 391 format = "%llu"; |
| 392 return sscanf(value_string.c_str(), format, value) == 1; | 392 return sscanf(value_string.c_str(), format, value) == 1; |
| 393 } | 393 } |
| 394 | 394 |
| 395 } // namespace | 395 } // namespace |
| 396 | 396 |
| 397 bool ParseValidationTestInput(const std::string& input, | 397 bool ParseValidationTestInput(const std::string& input, |
| 398 std::vector<uint8_t>* data, | 398 std::vector<uint8_t>* data, |
| 399 size_t* num_handles, | 399 size_t* num_handles, |
| 400 std::string* error_message) { | 400 std::string* error_message) { |
| 401 ValidationTestInputParser parser(input, data, num_handles, error_message); | 401 ValidationTestInputParser parser(input, data, num_handles, error_message); |
| 402 return parser.Run(); | 402 return parser.Run(); |
| 403 } | 403 } |
| 404 | 404 |
| 405 } // namespace test | 405 } // namespace test |
| 406 } // namespace mojo | 406 } // namespace mojo |
| OLD | NEW |