Changeset 1141 for trunk/libtorrent/test/torrent/object_static_map_test.cc
- Timestamp:
- 03/06/10 11:35:37 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtorrent/test/torrent/object_static_map_test.cc
r1140 r1141 4 4 #include <torrent/object_stream.h> 5 5 #include "torrent/object_static_map.h" 6 #include "protocol/extensions.h" 6 7 7 8 #import "object_test_utils.h" … … 150 151 151 152 CPPUNIT_ASSERT(static_map_read_bencode(test_skip_map, test_read_skip_bencode)); 153 } 154 155 template <> 156 const torrent::ExtHandshakeMessage::key_list_type torrent::ExtHandshakeMessage::keys = { 157 { key_e, "e" }, 158 { key_m_utPex, "m::ut_pex" }, 159 { key_p, "p" }, 160 { key_reqq, "reqq" }, 161 { key_v, "v" }, 162 }; 163 164 void 165 ObjectStaticMapTest::test_read_extensions() { 166 torrent::ExtHandshakeMessage test_ext; 167 168 CPPUNIT_ASSERT(static_map_read_bencode(test_ext, "d1:ai1ee")); 169 170 CPPUNIT_ASSERT(static_map_read_bencode(test_ext, "d1:mi1ee")); 171 CPPUNIT_ASSERT(static_map_read_bencode(test_ext, "d1:mdee")); 172 CPPUNIT_ASSERT(static_map_read_bencode(test_ext, "d6:ut_pexi0ee")); 173 CPPUNIT_ASSERT(static_map_read_bencode(test_ext, "d1:md6:ut_pexi0eee")); 152 174 } 153 175 … … 176 198 enum keys_raw_types { key_raw_types_empty, key_raw_types_list, key_raw_types_map, key_raw_types_str, key_raw_types_LAST}; 177 199 enum keys_multiple { key_multiple_a, key_multiple_b, key_multiple_c, key_multiple_LAST }; 200 enum keys_dict { key_dict_a_b, key_dict_LAST }; 178 201 179 202 typedef torrent::static_map_type<keys_empty, key_empty_LAST> test_empty_type; … … 182 205 typedef torrent::static_map_type<keys_raw_types, key_raw_types_LAST> test_raw_types_type; 183 206 typedef torrent::static_map_type<keys_multiple, key_multiple_LAST> test_multiple_type; 207 typedef torrent::static_map_type<keys_dict, key_dict_LAST> test_dict_type; 184 208 185 209 template <> const test_empty_type::key_list_type … … 196 220 template <> const test_multiple_type::key_list_type 197 221 test_multiple_type::keys = { { key_multiple_a, "a" }, { key_multiple_b, "b*" }, { key_multiple_c, "c" } }; 222 template <> const test_dict_type::key_list_type 223 test_dict_type::keys = { { key_dict_a_b, "a::b" } }; 198 224 199 225 void … … 290 316 291 317 void 318 ObjectStaticMapTest::test_read_dict() { 319 test_dict_type map_normal; 320 321 CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:ai1ee")); 322 CPPUNIT_ASSERT(map_normal[key_dict_a_b].is_empty()); 323 324 CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:adee")); 325 CPPUNIT_ASSERT(map_normal[key_dict_a_b].is_empty()); 326 327 CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:ad1:bi1eee")); 328 CPPUNIT_ASSERT(map_normal[key_dict_a_b].as_value() == 1); 329 } 330 331 void 292 332 ObjectStaticMapTest::test_write_empty() { 293 333 test_empty_type map_normal;
