Update style to (almost) conform to ndn-cxx style using clang-format
diff --git a/tests/unit-tests/serve-and-fetch.t.cpp b/tests/unit-tests/serve-and-fetch.t.cpp
index 8e8a3c6..d9aa6c7 100644
--- a/tests/unit-tests/serve-and-fetch.t.cpp
+++ b/tests/unit-tests/serve-and-fetch.t.cpp
@@ -18,22 +18,22 @@
* See AUTHORS.md for complete list of ChronoShare authors and contributors.
*/
-#include "fetch-manager.hpp"
-#include "ccnx-wrapper.hpp"
#include "ccnx-common.hpp"
-#include "scheduler.hpp"
+#include "ccnx-wrapper.hpp"
+#include "content-server.hpp"
+#include "fetch-manager.hpp"
#include "object-db.hpp"
#include "object-manager.hpp"
-#include "content-server.hpp"
-#include <boost/test/unit_test.hpp>
-#include <boost/make_shared.hpp>
+#include "scheduler.hpp"
#include <boost/filesystem.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/thread_time.hpp>
+#include <boost/make_shared.hpp>
+#include <boost/test/unit_test.hpp>
#include <boost/thread/condition_variable.hpp>
-#include <stdio.h>
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread_time.hpp>
#include <ctime>
+#include <stdio.h>
#include "logging.hpp"
@@ -55,19 +55,18 @@
bool finished;
int ack;
-void setup()
+void
+setup()
{
- if (exists(root))
- {
+ if (exists(root)) {
remove_all(root);
}
create_directory(root);
// create file
- FILE *fp = fopen(filePath.string().c_str(), "w");
- for (int i = 0; i < repeat; i++)
- {
+ FILE* fp = fopen(filePath.string().c_str(), "w");
+ for (int i = 0; i < repeat; i++) {
fwrite(&magic, 1, sizeof(magic), fp);
}
fclose(fp);
@@ -76,10 +75,10 @@
finished = false;
}
-void teardown()
+void
+teardown()
{
- if (exists(root))
- {
+ if (exists(root)) {
remove_all(root);
}
@@ -88,25 +87,24 @@
}
Name
-simpleMap(const Name &deviceName)
+simpleMap(const Name& deviceName)
{
return Name("/local");
}
void
-segmentCallback(const Name &deviceName, const Name &baseName, uint64_t seq, PcoPtr pco)
+segmentCallback(const Name& deviceName, const Name& baseName, uint64_t seq, PcoPtr pco)
{
ack++;
Bytes co = pco->content();
int size = co.size();
- for (int i = 0; i < size; i++)
- {
+ for (int i = 0; i < size; i++) {
BOOST_CHECK_EQUAL(co[i], magic);
}
}
void
-finishCallback(Name &deviceName, Name &baseName)
+finishCallback(Name& deviceName, Name& baseName)
{
BOOST_CHECK_EQUAL(ack, repeat / 1024);
unique_lock<mutex> lock(mut);
@@ -114,11 +112,11 @@
cond.notify_one();
}
-BOOST_AUTO_TEST_CASE (TestServeAndFetch)
+BOOST_AUTO_TEST_CASE(TestServeAndFetch)
{
- INIT_LOGGERS ();
+ INIT_LOGGERS();
- _LOG_DEBUG ("Setting up test environment ...");
+ _LOG_DEBUG("Setting up test environment ...");
setup();
NdnxWrapperPtr ndnx_serve = make_shared<NdnxWrapper>();
@@ -132,38 +130,38 @@
const string APPNAME = "test-chronoshare";
time_t start = time(NULL);
- _LOG_DEBUG ("At time " << start << ", publish local file to database, this is extremely slow ...");
+ _LOG_DEBUG("At time " << start << ", publish local file to database, this is extremely slow ...");
// publish file to db
ObjectManager om(ndnx_serve, root, APPNAME);
tuple<HashPtr, size_t> pub = om.localFileToObjects(filePath, deviceName);
time_t end = time(NULL);
- _LOG_DEBUG ("At time " << end <<", publish finally finished, used " << end - start << " seconds ...");
+ _LOG_DEBUG("At time " << end << ", publish finally finished, used " << end - start
+ << " seconds ...");
ActionLogPtr dummyLog;
ContentServer server(ndnx_serve, dummyLog, root, deviceName, "pentagon's secrets", APPNAME, 5);
server.registerPrefix(localPrefix);
server.registerPrefix(broadcastPrefix);
- FetchManager fm(ndnx_fetch, bind(simpleMap, _1), Name("/local/broadcast"));
- HashPtr hash = pub.get<0> ();
- Name baseName = Name ("/")(deviceName)(APPNAME)("file")(hash->GetHash(), hash->GetHashBytes());
+ FetchManager fm(ccnx_fetch, bind(simpleMap, _1), Name("/local/broadcast"));
+ HashPtr hash = pub.get<0>();
+ Name baseName = Name("/")(deviceName)(APPNAME)("file")(hash->GetHash(), hash->GetHashBytes());
- fm.Enqueue(deviceName, baseName, bind(segmentCallback, _1, _2, _3, _4), bind(finishCallback, _1, _2), 0, pub.get<1>() - 1);
+ fm.Enqueue(deviceName, baseName, bind(segmentCallback, _1, _2, _3, _4),
+ bind(finishCallback, _1, _2), 0, pub.get<1>() - 1);
unique_lock<mutex> lock(mut);
system_time timeout = get_system_time() + posix_time::milliseconds(5000);
- while (!finished)
- {
- if (!cond.timed_wait(lock, timeout))
- {
- BOOST_FAIL ("Fetching has not finished after 5 seconds");
- break;
- }
+ while (!finished) {
+ if (!cond.timed_wait(lock, timeout)) {
+ BOOST_FAIL("Fetching has not finished after 5 seconds");
+ break;
}
- ndnx_fetch->shutdown ();
- ndnx_serve->shutdown ();
+ }
+ ccnx_fetch->shutdown();
+ ccnx_serve->shutdown();
- _LOG_DEBUG ("Finish");
+ _LOG_DEBUG("Finish");
usleep(100000);
teardown();