summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-10-15 19:02:54 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2016-10-15 19:02:54 +0900
commitaa4ea8889c827df4b178b6ae6259b82e86bfbc5f (patch)
tree5e527bbdeb4f1703c615827ede961e11c2983440 /test
parenta7fcf83bdfabf213d80e32d72561764f82e6782d (diff)
clang-format-3.9
Diffstat (limited to 'test')
-rw-r--r--test/BtRegistryTest.cc8
-rw-r--r--test/CookieStorageTest.cc10
-rw-r--r--test/IndexedListTest.cc2
-rw-r--r--test/MockDHTMessageDispatcher.h17
-rw-r--r--test/RpcMethodTest.cc57
-rw-r--r--test/UtilSecurityTest.cc74
-rw-r--r--test/UtilTest2.cc5
-rw-r--r--test/ValueBaseJsonParserTest.cc6
8 files changed, 95 insertions, 84 deletions
diff --git a/test/BtRegistryTest.cc b/test/BtRegistryTest.cc
index a1ace554..d6324e73 100644
--- a/test/BtRegistryTest.cc
+++ b/test/BtRegistryTest.cc
@@ -70,10 +70,10 @@ void BtRegistryTest::testGetDownloadContext_infoHash()
attrs1->infoHash = "hash1";
auto attrs2 = make_unique<TorrentAttribute>();
attrs2->infoHash = "hash2";
- btRegistry.getDownloadContext(1)
- ->setAttribute(CTX_ATTR_BT, std::move(attrs1));
- btRegistry.getDownloadContext(2)
- ->setAttribute(CTX_ATTR_BT, std::move(attrs2));
+ btRegistry.getDownloadContext(1)->setAttribute(CTX_ATTR_BT,
+ std::move(attrs1));
+ btRegistry.getDownloadContext(2)->setAttribute(CTX_ATTR_BT,
+ std::move(attrs2));
}
CPPUNIT_ASSERT(btRegistry.getDownloadContext("hash1"));
CPPUNIT_ASSERT(btRegistry.getDownloadContext("hash1").get() ==
diff --git a/test/CookieStorageTest.cc b/test/CookieStorageTest.cc
index a9966a64..9bd94dfa 100644
--- a/test/CookieStorageTest.cc
+++ b/test/CookieStorageTest.cc
@@ -77,8 +77,9 @@ void CookieStorageTest::testStore()
CPPUNIT_ASSERT_EQUAL((size_t)1, st.size());
CPPUNIT_ASSERT(st.contains(*goodCookie()));
- auto anotherCookie =
- []() { return createCookie("k", "v", "mirror", true, "/", true); };
+ auto anotherCookie = []() {
+ return createCookie("k", "v", "mirror", true, "/", true);
+ };
CPPUNIT_ASSERT(st.store(anotherCookie(), now));
CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
CPPUNIT_ASSERT(st.contains(*anotherCookie()));
@@ -107,8 +108,9 @@ void CookieStorageTest::testStore()
CPPUNIT_ASSERT_EQUAL((size_t)1, st.size());
CPPUNIT_ASSERT(st.contains(*anotherCookie()));
- auto fromNumericHost =
- []() { return createCookie("k", "v", "192.168.1.1", true, "/", false); };
+ auto fromNumericHost = []() {
+ return createCookie("k", "v", "192.168.1.1", true, "/", false);
+ };
CPPUNIT_ASSERT(st.store(fromNumericHost(), now));
CPPUNIT_ASSERT_EQUAL((size_t)2, st.size());
CPPUNIT_ASSERT(st.contains(*fromNumericHost()));
diff --git a/test/IndexedListTest.cc b/test/IndexedListTest.cc
index 7b8878c8..d3c05a55 100644
--- a/test/IndexedListTest.cc
+++ b/test/IndexedListTest.cc
@@ -109,7 +109,7 @@ void IndexedListTest::testErase()
CPPUNIT_ASSERT_EQUAL((size_t)(std::distance(i, list.end())), list.size());
int* pp = ++p;
- for (IndexedList<int, int*>::iterator j = list.begin(); j != list.end();
+ for (IndexedList<int, int *>::iterator j = list.begin(); j != list.end();
++j, ++pp) {
CPPUNIT_ASSERT_EQUAL(*pp, **j);
}
diff --git a/test/MockDHTMessageDispatcher.h b/test/MockDHTMessageDispatcher.h
index 7c36c49d..b0616e94 100644
--- a/test/MockDHTMessageDispatcher.h
+++ b/test/MockDHTMessageDispatcher.h
@@ -29,19 +29,20 @@ public:
public:
MockDHTMessageDispatcher() {}
- virtual void addMessageToQueue(
- std::unique_ptr<DHTMessage> message, std::chrono::seconds timeout,
- std::unique_ptr<DHTMessageCallback>
- callback = std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE
+ virtual void
+ addMessageToQueue(std::unique_ptr<DHTMessage> message,
+ std::chrono::seconds timeout,
+ std::unique_ptr<DHTMessageCallback> callback =
+ std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE
{
messageQueue_.push_back(
Entry(std::move(message), std::move(timeout), std::move(callback)));
}
- virtual void addMessageToQueue(
- std::unique_ptr<DHTMessage> message,
- std::unique_ptr<DHTMessageCallback>
- callback = std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE
+ virtual void
+ addMessageToQueue(std::unique_ptr<DHTMessage> message,
+ std::unique_ptr<DHTMessageCallback> callback =
+ std::unique_ptr<DHTMessageCallback>{}) CXX11_OVERRIDE
{
messageQueue_.push_back(
Entry(std::move(message), DHT_MESSAGE_TIMEOUT, std::move(callback)));
diff --git a/test/RpcMethodTest.cc b/test/RpcMethodTest.cc
index 501d9c7e..f85fd0dd 100644
--- a/test/RpcMethodTest.cc
+++ b/test/RpcMethodTest.cc
@@ -340,14 +340,15 @@ RpcRequest createAddTorrentReq()
void RpcMethodTest::testAddTorrent()
{
File(e_->getOption()->get(PREF_DIR) +
- "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").remove();
+ "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent")
+ .remove();
AddTorrentRpcMethod m;
{
// Saving upload metadata is disabled by option.
auto res = m.execute(createAddTorrentReq(), e_.get());
- CPPUNIT_ASSERT(
- !File(e_->getOption()->get(PREF_DIR) +
- "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").exists());
+ CPPUNIT_ASSERT(!File(e_->getOption()->get(PREF_DIR) +
+ "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent")
+ .exists());
CPPUNIT_ASSERT_EQUAL(0, res.code);
CPPUNIT_ASSERT_EQUAL(sizeof(a2_gid_t) * 2,
downcast<String>(res.param)->s().size());
@@ -355,9 +356,9 @@ void RpcMethodTest::testAddTorrent()
e_->getOption()->put(PREF_RPC_SAVE_UPLOAD_METADATA, A2_V_TRUE);
{
auto res = m.execute(createAddTorrentReq(), e_.get());
- CPPUNIT_ASSERT(
- File(e_->getOption()->get(PREF_DIR) +
- "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent").exists());
+ CPPUNIT_ASSERT(File(e_->getOption()->get(PREF_DIR) +
+ "/0a3893293e27ac0490424c06de4d09242215f0a6.torrent")
+ .exists());
CPPUNIT_ASSERT_EQUAL(0, res.code);
a2_gid_t gid;
CPPUNIT_ASSERT_EQUAL(
@@ -457,7 +458,8 @@ RpcRequest createAddMetalinkReq()
void RpcMethodTest::testAddMetalink()
{
File(e_->getOption()->get(PREF_DIR) +
- "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").remove();
+ "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
+ .remove();
AddMetalinkRpcMethod m;
{
// Saving upload metadata is disabled by option.
@@ -472,9 +474,9 @@ void RpcMethodTest::testAddMetalink()
CPPUNIT_ASSERT_EQUAL(
0, GroupId::toNumericId(
gid2, downcast<String>(resParams->get(1))->s().c_str()));
- CPPUNIT_ASSERT(
- !File(e_->getOption()->get(PREF_DIR) +
- "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists());
+ CPPUNIT_ASSERT(!File(e_->getOption()->get(PREF_DIR) +
+ "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
+ .exists());
}
e_->getOption()->put(PREF_RPC_SAVE_UPLOAD_METADATA, A2_V_TRUE);
{
@@ -489,9 +491,9 @@ void RpcMethodTest::testAddMetalink()
CPPUNIT_ASSERT_EQUAL(
0, GroupId::toNumericId(
gid4, downcast<String>(resParams->get(1))->s().c_str()));
- CPPUNIT_ASSERT(
- File(e_->getOption()->get(PREF_DIR) +
- "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4").exists());
+ CPPUNIT_ASSERT(File(e_->getOption()->get(PREF_DIR) +
+ "/c908634fbc257fd56f0114912c2772aeeb4064f4.meta4")
+ .exists());
auto tar = findReservedGroup(e_->getRequestGroupMan().get(), gid3);
CPPUNIT_ASSERT(tar);
@@ -1018,8 +1020,10 @@ void RpcMethodTest::testGatherProgressCommon()
CPPUNIT_ASSERT_EQUAL(std::string("aria2.tar.bz2"),
downcast<String>(file->get("path"))->s());
CPPUNIT_ASSERT_EQUAL(
- uris[0], downcast<String>(downcast<Dict>(downcast<List>(file->get("uris"))
- ->get(0))->get("uri"))->s());
+ uris[0],
+ downcast<String>(
+ downcast<Dict>(downcast<List>(file->get("uris"))->get(0))->get("uri"))
+ ->s());
CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR),
downcast<String>(entry->get("dir"))->s());
@@ -1389,15 +1393,18 @@ void RpcMethodTest::testSystemMulticall()
CPPUNIT_ASSERT_EQUAL(
GroupId::toHex(getReservedGroup(rgman.get(), 1)->getGID()),
downcast<String>(downcast<List>(resParams->get(1))->get(0))->s());
- CPPUNIT_ASSERT_EQUAL((int64_t)1,
- downcast<Integer>(downcast<Dict>(resParams->get(2))
- ->get("faultCode"))->i());
- CPPUNIT_ASSERT_EQUAL((int64_t)1,
- downcast<Integer>(downcast<Dict>(resParams->get(3))
- ->get("faultCode"))->i());
- CPPUNIT_ASSERT_EQUAL((int64_t)1,
- downcast<Integer>(downcast<Dict>(resParams->get(4))
- ->get("faultCode"))->i());
+ CPPUNIT_ASSERT_EQUAL(
+ (int64_t)1,
+ downcast<Integer>(downcast<Dict>(resParams->get(2))->get("faultCode"))
+ ->i());
+ CPPUNIT_ASSERT_EQUAL(
+ (int64_t)1,
+ downcast<Integer>(downcast<Dict>(resParams->get(3))->get("faultCode"))
+ ->i());
+ CPPUNIT_ASSERT_EQUAL(
+ (int64_t)1,
+ downcast<Integer>(downcast<Dict>(resParams->get(4))->get("faultCode"))
+ ->i());
CPPUNIT_ASSERT(downcast<List>(resParams->get(5)));
CPPUNIT_ASSERT(downcast<List>(resParams->get(6)));
}
diff --git a/test/UtilSecurityTest.cc b/test/UtilSecurityTest.cc
index 64f7c191..dfeaa543 100644
--- a/test/UtilSecurityTest.cc
+++ b/test/UtilSecurityTest.cc
@@ -24,7 +24,7 @@ static struct hmachash {
"\x0b\x0b\x0b\x0b\x0b"},
{20},
{
- "\x48\x69\x20\x54\x68\x65\x72\x65" /* "Hi There" */
+ "\x48\x69\x20\x54\x68\x65\x72\x65" /* "Hi There" */
},
{8},
{/* HMAC-SHA-1 */
@@ -48,9 +48,9 @@ static struct hmachash {
},
{4},
{
- "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74"
- "\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f"
- /* "what do ya want for nothing?" */
+ "\x77\x68\x61\x74\x20\x64\x6f\x20\x79\x61\x20\x77\x61\x6e\x74"
+ "\x20\x66\x6f\x72\x20\x6e\x6f\x74\x68\x69\x6e\x67\x3f"
+ /* "what do ya want for nothing?" */
},
{28},
{/* HMAC-SHA-1 */
@@ -173,22 +173,22 @@ static struct hmachash {
"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa"},
{80, 131},
{
- "Test Using Larger Than Block-Size Key and "
- "Larger Than One Block-Size Data",
- "\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x74\x65\x73\x74\x20"
- "\x75\x73\x69\x6e\x67\x20\x61\x20\x6c\x61\x72\x67\x65\x72\x20"
- "\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73\x69\x7a\x65"
- "\x20\x6b\x65\x79\x20\x61\x6e\x64\x20\x61\x20\x6c\x61\x72\x67"
- "\x65\x72\x20\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73"
- "\x69\x7a\x65\x20\x64\x61\x74\x61\x2e\x20\x54\x68\x65\x20\x6b"
- "\x65\x79\x20\x6e\x65\x65\x64\x73\x20\x74\x6f\x20\x62\x65\x20"
- "\x68\x61\x73\x68\x65\x64\x20\x62\x65\x66\x6f\x72\x65\x20\x62"
- "\x65\x69\x6e\x67\x20\x75\x73\x65\x64\x20\x62\x79\x20\x74\x68"
- "\x65\x20\x48\x4d\x41\x43\x20\x61\x6c\x67\x6f\x72\x69\x74\x68"
- "\x6d\x2e"
- /* "This is a test using a larger than block-size key and a "
- "larger than block-size data. The key needs to be hashed "
- "before being used by the HMAC algorithm." */
+ "Test Using Larger Than Block-Size Key and "
+ "Larger Than One Block-Size Data",
+ "\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x74\x65\x73\x74\x20"
+ "\x75\x73\x69\x6e\x67\x20\x61\x20\x6c\x61\x72\x67\x65\x72\x20"
+ "\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73\x69\x7a\x65"
+ "\x20\x6b\x65\x79\x20\x61\x6e\x64\x20\x61\x20\x6c\x61\x72\x67"
+ "\x65\x72\x20\x74\x68\x61\x6e\x20\x62\x6c\x6f\x63\x6b\x2d\x73"
+ "\x69\x7a\x65\x20\x64\x61\x74\x61\x2e\x20\x54\x68\x65\x20\x6b"
+ "\x65\x79\x20\x6e\x65\x65\x64\x73\x20\x74\x6f\x20\x62\x65\x20"
+ "\x68\x61\x73\x68\x65\x64\x20\x62\x65\x66\x6f\x72\x65\x20\x62"
+ "\x65\x69\x6e\x67\x20\x75\x73\x65\x64\x20\x62\x79\x20\x74\x68"
+ "\x65\x20\x48\x4d\x41\x43\x20\x61\x6c\x67\x6f\x72\x69\x74\x68"
+ "\x6d\x2e"
+ /* "This is a test using a larger than block-size key and a "
+ "larger than block-size data. The key needs to be hashed "
+ "before being used by the HMAC algorithm." */
},
{73, 152},
{/* HMAC-SHA-1 */
@@ -342,32 +342,32 @@ static struct pbkdf2 {
"salt",
4,
1,
- {0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9, 0xb5, 0x24,
- 0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6},
+ {0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9,
+ 0xb5, 0x24, 0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6},
20},
{"password",
8,
"salt",
4,
1,
- {0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9, 0xb5, 0x24,
- 0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6},
+ {0x0c, 0x60, 0xc8, 0x0f, 0x96, 0x1f, 0x0e, 0x71, 0xf3, 0xa9,
+ 0xb5, 0x24, 0xaf, 0x60, 0x12, 0x06, 0x2f, 0xe0, 0x37, 0xa6},
0},
{"password",
8,
"salt",
4,
2,
- {0xea, 0x6c, 0x01, 0x4d, 0xc7, 0x2d, 0x6f, 0x8c, 0xcd, 0x1e, 0xd9, 0x2a,
- 0xce, 0x1d, 0x41, 0xf0, 0xd8, 0xde, 0x89, 0x57},
+ {0xea, 0x6c, 0x01, 0x4d, 0xc7, 0x2d, 0x6f, 0x8c, 0xcd, 0x1e,
+ 0xd9, 0x2a, 0xce, 0x1d, 0x41, 0xf0, 0xd8, 0xde, 0x89, 0x57},
20},
{"password",
8,
"salt",
4,
4096,
- {0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48, 0x9a, 0xbe, 0xad, 0x49, 0xd9,
- 0x26, 0xf7, 0x21, 0xd0, 0x65, 0xa4, 0x29, 0xc1},
+ {0x4b, 0x00, 0x79, 0x01, 0xb7, 0x65, 0x48, 0x9a, 0xbe, 0xad,
+ 0x49, 0xd9, 0x26, 0xf7, 0x21, 0xd0, 0x65, 0xa4, 0x29, 0xc1},
20},
/* Disabled due to #236
{
@@ -380,15 +380,15 @@ static struct pbkdf2 {
},
*/
{
- "passwordPASSWORDpassword",
- 24,
- "saltSALTsaltSALTsaltSALTsaltSALTsalt",
- 36,
- 4096,
- {0x3d, 0x2e, 0xec, 0x4f, 0xe4, 0x1c, 0x84, 0x9b, 0x80, 0xc8, 0xd8, 0x36,
- 0x62, 0xc0, 0xe4, 0x4a, 0x8b, 0x29, 0x1a, 0x96, 0x4c, 0xf2, 0xf0, 0x70,
- 0x38},
- 25,
+ "passwordPASSWORDpassword",
+ 24,
+ "saltSALTsaltSALTsaltSALTsaltSALTsalt",
+ 36,
+ 4096,
+ {0x3d, 0x2e, 0xec, 0x4f, 0xe4, 0x1c, 0x84, 0x9b, 0x80,
+ 0xc8, 0xd8, 0x36, 0x62, 0xc0, 0xe4, 0x4a, 0x8b, 0x29,
+ 0x1a, 0x96, 0x4c, 0xf2, 0xf0, 0x70, 0x38},
+ 25,
},
{"pass\0word",
9,
diff --git a/test/UtilTest2.cc b/test/UtilTest2.cc
index 544df0d5..b919b71c 100644
--- a/test/UtilTest2.cc
+++ b/test/UtilTest2.cc
@@ -670,8 +670,9 @@ void UtilTest2::testGenerateRandomData()
double mean = sum / counts.size();
vector<double> diff(counts.size());
transform(counts.begin(), counts.end(), diff.begin(),
- [&](const decltype(counts)::value_type& elem)
- -> double { return (double)elem.second - mean; });
+ [&](const decltype(counts)::value_type& elem) -> double {
+ return (double)elem.second - mean;
+ });
double sq_sum = inner_product(diff.begin(), diff.end(), diff.begin(), 0.0);
double stddev = sqrt(sq_sum / counts.size());
cout << "stddev: " << fixed << stddev << endl;
diff --git a/test/ValueBaseJsonParserTest.cc b/test/ValueBaseJsonParserTest.cc
index 9a2b5faa..6f9edaf9 100644
--- a/test/ValueBaseJsonParserTest.cc
+++ b/test/ValueBaseJsonParserTest.cc
@@ -177,13 +177,13 @@ void ValueBaseJsonParserTest::testParseUpdate()
const Integer* i = downcast<Integer>(list->get(0));
CPPUNIT_ASSERT_EQUAL((Integer::ValueType)0, i->i());
const Integer* i1 = downcast<Integer>(list->get(1));
- CPPUNIT_ASSERT_EQUAL((Integer::ValueType) - 1, i1->i());
+ CPPUNIT_ASSERT_EQUAL((Integer::ValueType)-1, i1->i());
const Integer* i2 = downcast<Integer>(list->get(2));
CPPUNIT_ASSERT_EQUAL((Integer::ValueType)1, i2->i());
const Integer* i3 = downcast<Integer>(list->get(3));
- CPPUNIT_ASSERT_EQUAL((Integer::ValueType) - 1, i3->i());
+ CPPUNIT_ASSERT_EQUAL((Integer::ValueType)-1, i3->i());
const Integer* i4 = downcast<Integer>(list->get(4));
- CPPUNIT_ASSERT_EQUAL((Integer::ValueType) - 1, i4->i());
+ CPPUNIT_ASSERT_EQUAL((Integer::ValueType)-1, i4->i());
}
{
// escape chars: ", \, /, \b, \f, \n, \r, \t