1 // Copyright 2017 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "components/zucchini/test_utils.h" 6 7 #include <ios> 8 #include <sstream> 9 10 #include "base/check_op.h" 11 12 namespace zucchini { 13 ParseHexString(const std::string & hex_string)14std::vector<uint8_t> ParseHexString(const std::string& hex_string) { 15 std::vector<uint8_t> ret; 16 std::istringstream iss(hex_string); 17 iss >> std::hex; 18 uint32_t temp = 0; // Cannot be uint8_t: istringstream treats this as char! 19 while (iss >> temp) { 20 CHECK_LE(temp, 0xFFU); 21 ret.push_back(temp); 22 } 23 return ret; 24 } 25 26 } // namespace zucchini 27