Source: tests/io/roundtrip.cpp
15 #include <myramath/io/detail/complex.h> 16 #include <myramath/io/detail/pair.h> 17 #include <myramath/io/detail/string.h> 20 #include <myramath/io/detail/vector.h> 21 #include <myramath/io/detail/list.h> 22 #ifdef MYRAMATH_ENABLE_CPP11 23 #include <myramath/io/detail/array.h> 27 #include <myramath/io/detail/map.h> 28 #include <myramath/io/detail/set.h> 29 #ifdef MYRAMATH_ENABLE_CPP11 30 #include <myramath/io/detail/unordered_map.h> 31 #include <myramath/io/detail/unordered_set.h> 35 #include <tests/myratest.h> 42 template<
class T>
void test(
const T& t1)
46 T t2 = inout.read<T>();
47 bool equivalent = (t1 == t2);
54 ADD_TEST(
"roundtrip_pod",
"[io]")
60 test<double>( std::sqrt(2.0) );
64 ADD_TEST(
"roundtrip_struct",
"[io]")
66 typedef std::complex<float> C;
67 test<C>(C(0.8f,6.2f));
68 typedef std::complex<double> Z;
70 typedef std::pair<int,double> P;
75 ADD_TEST(
"roundtrip_sequence",
"[io]")
78 test<std::string> (
"hello");
79 typedef std::vector<float> V;
81 V v; v.push_back(1.0f); v.push_back(3.14159f); v.push_back(2.71828f);
84 typedef std::list<double> L;
85 L l; l.push_back(1.0); l.push_back(4.0); l.push_back(9.0); l.push_back(16.0);
87 #ifdef MYRAMATH_ENABLE_CPP11 89 typedef std::array<int,3> A;
90 test<A>( A({5,2,9}) );
95 ADD_TEST(
"roundtrip_associative",
"[io]")
98 typedef std::set< std::string > S;
99 S s; s.insert(
"apple"); s.insert(
"orange"); s.insert(
"grape");
102 typedef std::map<int,std::string> M;
103 M m; m[0] =
"zero"; m[1] =
"one"; m[3] =
"three";
105 #ifdef MYRAMATH_ENABLE_CPP11 107 typedef std::unordered_set<int> US;
108 US us; us.insert(2); us.insert(3); us.insert(5); us.insert(7); us.insert(9);
111 typedef std::unordered_map< std::string, std::string > UM;
112 UM um; um[
"KY"] =
"Kentucky"; um[
"OH"] =
"Ohio"; um[
"IA"] =
"Indiana";
Wraps a std::vector<char>, presents it as both an InputStream and OutputStream. Useful for hygienic u...
Definition: VectorStream.h:22
A stream that serialize/deserializes to std::vector<char> buffer.
Results: [PASS]
Go back to Summary of /test
programs.