xref: /aosp_15_r20/external/zucchini/test_utils.h (revision a03ca8b91e029cd15055c20c78c2e087c84792e4)
1*a03ca8b9SKrzysztof Kosiński // Copyright 2017 The Chromium Authors. All rights reserved.
2*a03ca8b9SKrzysztof Kosiński // Use of this source code is governed by a BSD-style license that can be
3*a03ca8b9SKrzysztof Kosiński // found in the LICENSE file.
4*a03ca8b9SKrzysztof Kosiński 
5*a03ca8b9SKrzysztof Kosiński #ifndef COMPONENTS_ZUCCHINI_TEST_UTILS_H_
6*a03ca8b9SKrzysztof Kosiński #define COMPONENTS_ZUCCHINI_TEST_UTILS_H_
7*a03ca8b9SKrzysztof Kosiński 
8*a03ca8b9SKrzysztof Kosiński #include <stdint.h>
9*a03ca8b9SKrzysztof Kosiński 
10*a03ca8b9SKrzysztof Kosiński #include <string>
11*a03ca8b9SKrzysztof Kosiński #include <vector>
12*a03ca8b9SKrzysztof Kosiński 
13*a03ca8b9SKrzysztof Kosiński namespace zucchini {
14*a03ca8b9SKrzysztof Kosiński 
15*a03ca8b9SKrzysztof Kosiński // Parses space-separated list of byte hex values into list.
16*a03ca8b9SKrzysztof Kosiński std::vector<uint8_t> ParseHexString(const std::string& hex_string);
17*a03ca8b9SKrzysztof Kosiński 
18*a03ca8b9SKrzysztof Kosiński // Returns a vector that's the contatenation of two vectors of the same type.
19*a03ca8b9SKrzysztof Kosiński // Elements are copied by value.
20*a03ca8b9SKrzysztof Kosiński template <class T>
Cat(const std::vector<T> & a,const std::vector<T> & b)21*a03ca8b9SKrzysztof Kosiński std::vector<T> Cat(const std::vector<T>& a, const std::vector<T>& b) {
22*a03ca8b9SKrzysztof Kosiński   std::vector<T> ret(a);
23*a03ca8b9SKrzysztof Kosiński   ret.insert(ret.end(), b.begin(), b.end());
24*a03ca8b9SKrzysztof Kosiński   return ret;
25*a03ca8b9SKrzysztof Kosiński }
26*a03ca8b9SKrzysztof Kosiński 
27*a03ca8b9SKrzysztof Kosiński // Returns a subvector of a vector. Elements are copied by value.
28*a03ca8b9SKrzysztof Kosiński template <class T>
Sub(const std::vector<T> & a,size_t lo,size_t hi)29*a03ca8b9SKrzysztof Kosiński std::vector<T> Sub(const std::vector<T>& a, size_t lo, size_t hi) {
30*a03ca8b9SKrzysztof Kosiński   return std::vector<T>(a.begin() + lo, a.begin() + hi);
31*a03ca8b9SKrzysztof Kosiński }
32*a03ca8b9SKrzysztof Kosiński 
33*a03ca8b9SKrzysztof Kosiński }  // namespace zucchini
34*a03ca8b9SKrzysztof Kosiński 
35*a03ca8b9SKrzysztof Kosiński #endif  // COMPONENTS_ZUCCHINI_TEST_UTILS_H_
36