| 29 | |
| 30 | // Inserting and extracting arrays from a container T of type U |
| 31 | template <class T> void sequence_test( |
| 32 | type_id tid, const many<typename T::value_type>& values, const string& s) |
| 33 | { |
| 34 | T x(values.begin(), values.end()); |
| 35 | |
| 36 | value vx(x); // construct |
| 37 | ASSERT_EQUAL(tid, vx.type()); |
| 38 | ASSERT_EQUAL(x, get<T>(vx)); |
| 39 | ASSERT_EQUAL(x, coerce<T>(vx)); |
| 40 | { |
| 41 | T y; |
| 42 | get(vx, y); // Two argument get. |
| 43 | ASSERT_EQUAL(x, y); |
| 44 | } |
| 45 | { |
| 46 | T y; |
| 47 | coerce(vx, y); // Two argument coerce. |
| 48 | ASSERT_EQUAL(x, y); |
| 49 | } |
| 50 | value v2; // assign |
| 51 | v2 = x; |
| 52 | ASSERT_EQUAL(tid, v2.type()); |
| 53 | ASSERT_EQUAL(x, get<T>(v2)); |
| 54 | ASSERT_EQUAL(x, coerce<T>(v2)); |
| 55 | ASSERT_EQUAL(vx, v2); |
| 56 | |
| 57 | T y(x); |
| 58 | typename T::iterator it = y.begin(); |
| 59 | *y.begin() = *(++it); // Second element is bigger so y is lexicographically bigger than x |
| 60 | value vy(y); |
| 61 | ASSERT(vx != vy); |
| 62 | ASSERT(vx < vy); |
| 63 | ASSERT(vy > vx); |
| 64 | |
| 65 | ASSERT_EQUAL(s, to_string(vx)); |
| 66 | } |
| 67 | |
| 68 | template <class T, class U> void map_test(const U& values, const string& s) { |
| 69 | T m(values.begin(), values.end()); |