aboutsummaryrefslogtreecommitdiff
path: root/test_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'test_utils.h')
-rw-r--r--test_utils.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/test_utils.h b/test_utils.h
index 7ed735d..e922343 100644
--- a/test_utils.h
+++ b/test_utils.h
@@ -15,6 +15,21 @@ 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_