aboutsummaryrefslogtreecommitdiff
path: root/test_utils.h
blob: e922343e7a97285ce7c1755858d52ffa8a349c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_ZUCCHINI_TEST_UTILS_H_
#define COMPONENTS_ZUCCHINI_TEST_UTILS_H_

#include <stdint.h>

#include <string>
#include <vector>

namespace zucchini {

// Parses space-separated list of byte hex values into list.
std::vector<uint8_t> ParseHexString(const std::string& hex_string);

// Returns a vector that's the contatenation of two vectors of the same type.
// Elements are copied by value.
template <class T>
std::vector<T> Cat(const std::vector<T>& a, const std::vector<T>& b) {
  std::vector<T> ret(a);
  ret.insert(ret.end(), b.begin(), b.end());
  return ret;
}

// Returns a subvector of a vector. Elements are copied by value.
template <class T>
std::vector<T> Sub(const std::vector<T>& a, size_t lo, size_t hi) {
  return std::vector<T>(a.begin() + lo, a.begin() + hi);
}

}  // namespace zucchini

#endif  // COMPONENTS_ZUCCHINI_TEST_UTILS_H_