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