test_utils.cc 651 B

1234567891011121314151617181920212223242526
  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. #include "components/zucchini/test_utils.h"
  5. #include <ios>
  6. #include <sstream>
  7. #include "base/check_op.h"
  8. namespace zucchini {
  9. std::vector<uint8_t> ParseHexString(const std::string& hex_string) {
  10. std::vector<uint8_t> ret;
  11. std::istringstream iss(hex_string);
  12. iss >> std::hex;
  13. uint32_t temp = 0; // Cannot be uint8_t: istringstream treats this as char!
  14. while (iss >> temp) {
  15. CHECK_LE(temp, 0xFFU);
  16. ret.push_back(temp);
  17. }
  18. return ret;
  19. }
  20. } // namespace zucchini