diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-12-27 18:39:47 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2015-12-27 18:40:08 +0900 |
| commit | b1132d6b10cd3791b9529d7031d723fd0e2d8215 (patch) | |
| tree | 9ce465b42bf09372118335c7c619bb2b41869eaf /test/ValueBaseBencodeParserTest.cc | |
| parent | 4abad2f64c9ff80144a61c5a9c2bea144852b883 (diff) | |
make clang-format using clang-format-3.6
Diffstat (limited to 'test/ValueBaseBencodeParserTest.cc')
| -rw-r--r-- | test/ValueBaseBencodeParserTest.cc | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/test/ValueBaseBencodeParserTest.cc b/test/ValueBaseBencodeParserTest.cc index bc67b233..a24af6d3 100644 --- a/test/ValueBaseBencodeParserTest.cc +++ b/test/ValueBaseBencodeParserTest.cc @@ -6,24 +6,25 @@ namespace aria2 { -class ValueBaseBencodeParserTest:public CppUnit::TestFixture { +class ValueBaseBencodeParserTest : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(ValueBaseBencodeParserTest); CPPUNIT_TEST(testParseUpdate); CPPUNIT_TEST_SUITE_END(); + public: void testParseUpdate(); }; -CPPUNIT_TEST_SUITE_REGISTRATION( ValueBaseBencodeParserTest ); +CPPUNIT_TEST_SUITE_REGISTRATION(ValueBaseBencodeParserTest); namespace { void checkDecodeError(const std::string& src) { bittorrent::ValueBaseBencodeParser parser; ssize_t error; - std::shared_ptr<ValueBase> r = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> r = + parser.parseFinal(src.c_str(), src.size(), error); CPPUNIT_ASSERT(!r); CPPUNIT_ASSERT(error < 0); } @@ -36,51 +37,51 @@ void ValueBaseBencodeParserTest::testParseUpdate() { // empty string std::string src = "0:"; - std::shared_ptr<ValueBase> s = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> s = + parser.parseFinal(src.c_str(), src.size(), error); CPPUNIT_ASSERT_EQUAL(std::string(""), downcast<String>(s)->s()); } { // integer 0 std::string src = "i0e"; - std::shared_ptr<ValueBase> s = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> s = + parser.parseFinal(src.c_str(), src.size(), error); CPPUNIT_ASSERT_EQUAL((int64_t)0, downcast<Integer>(s)->i()); } { // empty dict std::string src = "de"; - std::shared_ptr<ValueBase> d = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> d = + parser.parseFinal(src.c_str(), src.size(), error); CPPUNIT_ASSERT(downcast<Dict>(d)->empty()); } { // empty list std::string src = "le"; - std::shared_ptr<ValueBase> l = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> l = + parser.parseFinal(src.c_str(), src.size(), error); CPPUNIT_ASSERT(downcast<List>(l)->empty()); } { // string std::string src = "3:foo"; - std::shared_ptr<ValueBase> s = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> s = + parser.parseFinal(src.c_str(), src.size(), error); CPPUNIT_ASSERT_EQUAL(std::string("foo"), downcast<String>(s)->s()); } { // integer std::string src = "i9223372036854775807e"; - std::shared_ptr<ValueBase> s = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> s = + parser.parseFinal(src.c_str(), src.size(), error); CPPUNIT_ASSERT_EQUAL((int64_t)9223372036854775807LL, downcast<Integer>(s)->i()); } { // dict, size 1 std::string src = "d3:fooi123ee"; - std::shared_ptr<ValueBase> d = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> d = + parser.parseFinal(src.c_str(), src.size(), error); Dict* dict = downcast<Dict>(d); CPPUNIT_ASSERT(dict); CPPUNIT_ASSERT(dict->get("foo")); @@ -90,8 +91,8 @@ void ValueBaseBencodeParserTest::testParseUpdate() { // dict, size 2 std::string src = "d3:fooi123e3:bar1:ee"; - std::shared_ptr<ValueBase> d = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> d = + parser.parseFinal(src.c_str(), src.size(), error); Dict* dict = downcast<Dict>(d); CPPUNIT_ASSERT(dict); CPPUNIT_ASSERT_EQUAL((size_t)2, dict->size()); @@ -105,8 +106,8 @@ void ValueBaseBencodeParserTest::testParseUpdate() { // list, size 1 std::string src = "l3:fooe"; - std::shared_ptr<ValueBase> l = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> l = + parser.parseFinal(src.c_str(), src.size(), error); List* list = downcast<List>(l); CPPUNIT_ASSERT(list); CPPUNIT_ASSERT_EQUAL((size_t)1, list->size()); @@ -116,21 +117,20 @@ void ValueBaseBencodeParserTest::testParseUpdate() { // list, size 2 std::string src = "l3:fooi123ee"; - std::shared_ptr<ValueBase> l = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> l = + parser.parseFinal(src.c_str(), src.size(), error); List* list = downcast<List>(l); CPPUNIT_ASSERT(list); CPPUNIT_ASSERT_EQUAL((size_t)2, list->size()); CPPUNIT_ASSERT_EQUAL(std::string("foo"), downcast<String>(list->get(0))->s()); - CPPUNIT_ASSERT_EQUAL((int64_t)123, - downcast<Integer>(list->get(1))->i()); + CPPUNIT_ASSERT_EQUAL((int64_t)123, downcast<Integer>(list->get(1))->i()); } { // string, integer and list in dict std::string src = "d4:name5:aria24:sizei12345678900e5:filesl3:bin3:docee"; - std::shared_ptr<ValueBase> r = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> r = + parser.parseFinal(src.c_str(), src.size(), error); const Dict* dict = downcast<Dict>(r); CPPUNIT_ASSERT(dict); CPPUNIT_ASSERT_EQUAL(std::string("aria2"), @@ -148,8 +148,8 @@ void ValueBaseBencodeParserTest::testParseUpdate() { // dict in list std::string src = "ld1:ki123eee"; - std::shared_ptr<ValueBase> r = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> r = + parser.parseFinal(src.c_str(), src.size(), error); const List* list = downcast<List>(r); CPPUNIT_ASSERT(list); CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), list->size()); @@ -161,14 +161,14 @@ void ValueBaseBencodeParserTest::testParseUpdate() { // empty key is allowed std::string src = "d0:1:ve"; - std::shared_ptr<ValueBase> s = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> s = + parser.parseFinal(src.c_str(), src.size(), error); } { // empty encoded data std::string src = ""; - std::shared_ptr<ValueBase> s = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> s = + parser.parseFinal(src.c_str(), src.size(), error); CPPUNIT_ASSERT(!s); } // integer, without ending 'e' @@ -184,13 +184,14 @@ void ValueBaseBencodeParserTest::testParseUpdate() // string with minus length checkDecodeError("-1:a"); // too deep structure - checkDecodeError(std::string(51, 'l')+std::string(51,'e')); - checkDecodeError(std::string(50, 'l')+"d3:fooi100ee"+std::string(50,'e')); + checkDecodeError(std::string(51, 'l') + std::string(51, 'e')); + checkDecodeError(std::string(50, 'l') + "d3:fooi100ee" + + std::string(50, 'e')); { // ignore trailing garbage at the end of the input. std::string src = "5:aria2trail"; - std::shared_ptr<ValueBase> s = parser.parseFinal(src.c_str(), src.size(), - error); + std::shared_ptr<ValueBase> s = + parser.parseFinal(src.c_str(), src.size(), error); CPPUNIT_ASSERT_EQUAL(std::string("aria2"), downcast<String>(s)->s()); // Get trailing garbage position CPPUNIT_ASSERT_EQUAL((ssize_t)7, error); |
