test_utils.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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. #ifndef COMPONENTS_ZUCCHINI_TEST_UTILS_H_
  5. #define COMPONENTS_ZUCCHINI_TEST_UTILS_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include <vector>
  9. namespace zucchini {
  10. // Parses space-separated list of byte hex values into list.
  11. std::vector<uint8_t> ParseHexString(const std::string& hex_string);
  12. // Returns a vector that's the contatenation of two vectors of the same type.
  13. // Elements are copied by value.
  14. template <class T>
  15. std::vector<T> Cat(const std::vector<T>& a, const std::vector<T>& b) {
  16. std::vector<T> ret(a);
  17. ret.insert(ret.end(), b.begin(), b.end());
  18. return ret;
  19. }
  20. // Returns a subvector of a vector. Elements are copied by value.
  21. template <class T>
  22. std::vector<T> Sub(const std::vector<T>& a, size_t lo, size_t hi) {
  23. return std::vector<T>(a.begin() + lo, a.begin() + hi);
  24. }
  25. } // namespace zucchini
  26. #endif // COMPONENTS_ZUCCHINI_TEST_UTILS_H_