1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 #include "gtest/gtest.h"
5 #include "rgw/rgw_torrent.h"
12 decode.bencode("foo", bl);
13 decode.bencode("bar", bl);
14 decode.bencode("baz", bl);
16 string s(bl.c_str(), bl.length());
18 ASSERT_STREQ("3:foo3:bar3:baz", s.c_str());
21 TEST(Bencode, Integers)
23 TorrentBencode decode;
26 decode.bencode(0, bl);
27 decode.bencode(-3, bl);
28 decode.bencode(7, bl);
30 string s(bl.c_str(), bl.length());
32 ASSERT_STREQ("i0ei-3ei7e", s.c_str());
37 TorrentBencode decode;
40 decode.bencode_dict(bl);
41 decode.bencode("foo", 5, bl);
42 decode.bencode("bar", "baz", bl);
43 decode.bencode_end(bl);
45 string s(bl.c_str(), bl.length());
47 ASSERT_STREQ("d3:fooi5e3:bar3:baze", s.c_str());
52 TorrentBencode decode;
55 decode.bencode_list(bl);
56 decode.bencode("foo", 5, bl);
57 decode.bencode("bar", "baz", bl);
58 decode.bencode_end(bl);
60 string s(bl.c_str(), bl.length());
62 ASSERT_STREQ("l3:fooi5e3:bar3:baze", s.c_str());