| 118 | } |
| 119 | |
| 120 | int main(int, char**) { |
| 121 | try { |
| 122 | int failed = 0; |
| 123 | scalar_test_group<value>(failed); |
| 124 | |
| 125 | // Sequence tests |
| 126 | RUN_TEST(failed, sequence_test<list<bool> >( |
| 127 | ARRAY, many<bool>() + false + true, "@PN_BOOL[false, true]")); |
| 128 | RUN_TEST(failed, sequence_test<vector<int> >( |
| 129 | ARRAY, many<int>() + -1 + 2, "@PN_INT[-1, 2]")); |
| 130 | RUN_TEST(failed, sequence_test<deque<string> >( |
| 131 | ARRAY, many<string>() + "a" + "b", "@PN_STRING[\"a\", \"b\"]")); |
| 132 | RUN_TEST(failed, sequence_test<deque<symbol> >( |
| 133 | ARRAY, many<symbol>() + "a" + "b", "@PN_SYMBOL[:a, :b]")); |
| 134 | RUN_TEST(failed, sequence_test<vector<value> >( |
| 135 | LIST, many<value>() + value(0) + value("a"), "[0, \"a\"]")); |
| 136 | RUN_TEST(failed, sequence_test<vector<scalar> >( |
| 137 | LIST, many<scalar>() + scalar(0) + scalar("a"), "[0, \"a\"]")); |
| 138 | |
| 139 | // // Map tests |
| 140 | typedef pair<string, uint64_t> si_pair; |
| 141 | many<si_pair> si_pairs; |
| 142 | si_pairs << si_pair("a", 0) << si_pair("b", 1) << si_pair("c", 2); |
| 143 | |
| 144 | RUN_TEST(failed, (map_test<map<string, uint64_t> >( |
| 145 | si_pairs, "{\"a\"=0, \"b\"=1, \"c\"=2}"))); |
| 146 | RUN_TEST(failed, (map_test<vector<si_pair> >( |
| 147 | si_pairs, "{\"a\"=0, \"b\"=1, \"c\"=2}"))); |
| 148 | |
| 149 | many<std::pair<value,value> > value_pairs(si_pairs); |
| 150 | RUN_TEST(failed, (map_test<map<value, value> >( |
| 151 | value_pairs, "{\"a\"=0, \"b\"=1, \"c\"=2}"))); |
| 152 | |
| 153 | many<pair<scalar,scalar> > scalar_pairs(si_pairs); |
| 154 | RUN_TEST(failed, (map_test<map<scalar, scalar> >( |
| 155 | scalar_pairs, "{\"a\"=0, \"b\"=1, \"c\"=2}"))); |
| 156 | |
| 157 | annotation_key ak(si_pairs[0].first); |
| 158 | pair<annotation_key, message_id> p(si_pairs[0]); |
| 159 | many<pair<annotation_key, message_id> > restricted_pairs(si_pairs); |
| 160 | RUN_TEST(failed, (map_test<map<annotation_key, message_id> >( |
| 161 | restricted_pairs, "{:a=0, :b=1, :c=2}"))); |
| 162 | RUN_TEST(failed, null_test()); |
| 163 | |
| 164 | RUN_TEST(failed, sequence_test<forward_list<binary> >( |
| 165 | ARRAY, many<binary>() + binary("xx") + binary("yy"), "@PN_BINARY[b\"xx\", b\"yy\"]")); |
| 166 | RUN_TEST(failed, (map_test<unordered_map<string, uint64_t> >(si_pairs, ""))); |
| 167 | |
| 168 | return failed; |
| 169 | } catch (const std::exception& e) { |
| 170 | std::cout << "ERROR in main(): " << e.what() << std::endl; |
| 171 | } |
| 172 | } |