Skip to content

Commit 07dcbe4

Browse files
tstennercboulay
authored andcommitted
Unit tests: apply clang-format
1 parent 29121cf commit 07dcbe4

11 files changed

+57
-44
lines changed

testing/bench_ext_bounce.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include "helpers.h"
21
#include "catch.hpp"
2+
#include "helpers.h"
33
#include <lsl_cpp.h>
44

55
TEST_CASE("bounce", "[basic][latency]") {

testing/bench_ext_common.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
TEST_CASE("common") {
55
BENCHMARK("lsl_clock") { return lsl_local_clock(); };
66
}
7-

testing/bench_ext_pushpull.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ TEMPLATE_TEST_CASE("pushpull", "[basic][throughput]", char, float, std::string)
1212
const std::size_t param_inlets[] = {0, 1, 10};
1313

1414
const TestType data[max_nchan * chunk_size] = {TestType()};
15-
//TestType data_out[max_n * chunk_size];
15+
// TestType data_out[max_n * chunk_size];
1616

1717
const char *name = SampleType<TestType>::fmt_string();
1818
lsl::channel_format_t cf = (lsl::channel_format_t)SampleType<TestType>::chan_fmt;
1919

2020
for (auto nchan : param_nchan) {
2121
lsl::stream_outlet out(
22-
lsl::stream_info(name, "PushPull", (int) nchan, lsl::IRREGULAR_RATE, cf, "streamid"));
22+
lsl::stream_info(name, "PushPull", (int)nchan, lsl::IRREGULAR_RATE, cf, "streamid"));
2323
auto found_stream_info(lsl::resolve_stream("name", name, 1, 2.0));
2424
REQUIRE(!found_stream_info.empty());
2525

@@ -30,15 +30,16 @@ TEMPLATE_TEST_CASE("pushpull", "[basic][throughput]", char, float, std::string)
3030
inlet_list.front().open_stream(.5);
3131
}
3232

33-
BENCHMARK("push_sample_nchan_" + std::to_string(nchan)+"_inlets_"+std::to_string(n_inlets)) {
33+
BENCHMARK("push_sample_nchan_" + std::to_string(nchan) + "_inlets_" +
34+
std::to_string(n_inlets)) {
3435
for (size_t s = 0; s < chunk_size; s++) out.push_sample(data);
3536
};
3637

37-
BENCHMARK("push_chunk_nchan_" + std::to_string(nchan)+"_inlets_"+std::to_string(n_inlets)) {
38+
BENCHMARK("push_chunk_nchan_" + std::to_string(nchan) + "_inlets_" +
39+
std::to_string(n_inlets)) {
3840
out.push_chunk_multiplexed(data, chunk_size);
3941
};
40-
for(auto &inlet: inlet_list)
41-
inlet.flush();
42+
for (auto &inlet : inlet_list) inlet.flush();
4243
}
4344
}
4445
}

testing/test_ext_DataType.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
#include "catch.hpp"
2-
#include "helpers.h"
32
#include "helper_type.hpp"
3+
#include "helpers.h"
44
#include <cstdint>
55
#include <lsl_cpp.h>
66

7-
TEMPLATE_TEST_CASE("datatransfer", "[datatransfer][basic]", char, int16_t, int32_t, int64_t, float, double) {
7+
TEMPLATE_TEST_CASE(
8+
"datatransfer", "[datatransfer][basic]", char, int16_t, int32_t, int64_t, float, double) {
89
const int numBounces = sizeof(TestType) * 8;
910
double timestamps[numBounces][2];
10-
const char* name = SampleType<TestType>::fmt_string();
11-
lsl::channel_format_t cf = (lsl::channel_format_t) SampleType<TestType>::chan_fmt;
11+
const char *name = SampleType<TestType>::fmt_string();
12+
lsl::channel_format_t cf = (lsl::channel_format_t)SampleType<TestType>::chan_fmt;
1213

1314
Streampair sp(create_streampair(
1415
lsl::stream_info(name, "Bounce", 2, lsl::IRREGULAR_RATE, cf, "streamid")));
@@ -37,8 +38,8 @@ TEMPLATE_TEST_CASE("datatransfer", "[datatransfer][basic]", char, int16_t, int32
3738
TEST_CASE("data datatransfer", "[datatransfer][multi][string]") {
3839
const std::size_t numChannels = 2;
3940

40-
Streampair sp(create_streampair(
41-
lsl::stream_info("cf_string", "DataType", numChannels, lsl::IRREGULAR_RATE, lsl::cf_string, "streamid")));
41+
Streampair sp(create_streampair(lsl::stream_info(
42+
"cf_string", "DataType", numChannels, lsl::IRREGULAR_RATE, lsl::cf_string, "streamid")));
4243

4344
std::vector<std::string> sent_data, received_data(numChannels);
4445
const char nullstr[] = "\0Test\0string\0with\0nulls";
@@ -49,23 +50,22 @@ TEST_CASE("data datatransfer", "[datatransfer][multi][string]") {
4950
CHECK(sp.in_.pull_sample(received_data, 5.) != 0.0);
5051
CHECK(received_data[0] == sent_data[0]);
5152
// Manually check second string for equality to avoid printing the entire test string
52-
if(received_data[1] != sent_data[1])
53+
if (received_data[1] != sent_data[1])
5354
FAIL("Sent large string data doesn't match received data");
5455
}
5556

5657
TEST_CASE("TypeConversion", "[datatransfer][types][basic]") {
57-
Streampair sp{
58-
create_streampair(lsl::stream_info("TypeConversion", "int2str2int", 1, 1, lsl::cf_string, "TypeConversion"))};
58+
Streampair sp{create_streampair(
59+
lsl::stream_info("TypeConversion", "int2str2int", 1, 1, lsl::cf_string, "TypeConversion"))};
5960
const int num_bounces = 31;
6061
std::vector<int32_t> data;
6162
for (int i = 0; i < num_bounces; ++i) data.push_back(1 << i);
6263

6364
sp.out_.push_chunk_multiplexed(data);
6465

65-
for (int32_t val: data) {
66+
for (int32_t val : data) {
6667
int32_t result;
6768
sp.in_.pull_sample(&result, 1, 1.);
6869
CHECK(result == val);
6970
}
7071
}
71-

testing/test_ext_move.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,4 @@ TEST_CASE("move C++ API types", "[move][basic]") {
6363
REQUIRE(found_stream_info.empty());
6464
}
6565

66-
}
66+
} // namespace

testing/test_ext_time.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#include "helpers.h"
21
#include "catch.hpp"
3-
#include <lsl_cpp.h>
2+
#include "helpers.h"
43
#include <atomic>
4+
#include <lsl_cpp.h>
55
#include <thread>
66

77
namespace {
@@ -21,11 +21,12 @@ TEST_CASE("simple timesync", "[timesync][basic]") {
2121

2222

2323
TEST_CASE("timeouts", "[pull][basic]") {
24-
auto sp = create_streampair(lsl::stream_info("timeouts", "Test", 1, lsl::IRREGULAR_RATE, lsl::cf_int8, "timeouts"));
24+
auto sp = create_streampair(
25+
lsl::stream_info("timeouts", "Test", 1, lsl::IRREGULAR_RATE, lsl::cf_int8, "timeouts"));
2526
std::atomic<bool> done{false};
2627

2728
// Push a sample after some time so the test can continue even if the timeout isn't honored
28-
std::thread saver([&](){
29+
std::thread saver([&]() {
2930
char val;
3031
auto end = lsl::local_clock() + 2;
3132
while (!done && lsl::local_clock() < end)

testing/test_int_asiocancel.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ const uint16_t port = 28812;
1818

1919
static std::mutex output_mutex;
2020

21-
#define MINFO(str) {std::unique_lock<std::mutex> out_lock(output_mutex); INFO(str)}
21+
#define MINFO(str) \
22+
{ \
23+
std::unique_lock<std::mutex> out_lock(output_mutex); \
24+
INFO(str) \
25+
}
2226

2327
template <typename T> void test_cancel_thread(T &&task, cancellable_streambuf &sb) {
2428
std::condition_variable cv;

testing/test_int_inireader.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
#include "catch.hpp"
33
#include <sstream>
44

5-
void try_load(INI& pt, const char* contents) {
5+
void try_load(INI &pt, const char *contents) {
66
std::istringstream stream{std::string(contents)};
77
pt.load(stream);
88
}
99

1010
TEST_CASE("ini files are parsed correctly", "[ini][basic]") {
1111
INI pt;
1212
try_load(pt, "x=5\n"
13-
"y=2\n"
14-
"[foo]\n"
15-
"foo=bar\n"
16-
"; foo=commented out\n"
17-
"double=equals=sign\n"
18-
"[white space]\n"
19-
"\tfoo =\t bar\r\n");
13+
"y=2\n"
14+
"[foo]\n"
15+
"foo=bar\n"
16+
"; foo=commented out\n"
17+
"double=equals=sign\n"
18+
"[white space]\n"
19+
"\tfoo =\t bar\r\n");
2020
CHECK(pt.get("doesntexist", 0) == 0);
2121
CHECK(pt.get<int>("defaultval") == 0);
2222
CHECK(pt.get<int>("x") == 5);

testing/test_int_samples.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ TEST_CASE("consumer_queue_threaded", "[queue][threads]") {
3838

3939
unsigned int n = 0, total = 0;
4040
// Pull samples until the pusher is done and the queue is empty
41-
while((n = queue.flush()) != 0 || !done) total+=n;
41+
while ((n = queue.flush()) != 0 || !done) total += n;
4242
CHECK(total == size);
4343
pusher.join();
4444
}

testing/test_int_streaminfo.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
#include "../src/stream_info_impl.h"
21
#include "../src/api_config.h"
2+
#include "../src/stream_info_impl.h"
33
#include "catch.hpp"
44

55
TEST_CASE("streaminfo matching via XPath", "[basic][streaminfo][xml]") {
66
lsl::stream_info_impl info(
77
"streamname", "streamtype", 8, 500, lsl_channel_format_t::cft_string, "sourceid");
88
auto channels = info.desc().append_child("channels");
9-
for(int i=0; i< 4;++i)
10-
channels.append_child("channel").append_child("type").append_child(pugi::node_pcdata).set_value("EEG");
11-
for(int i=0; i< 4;++i)
12-
channels.append_child("channel").append_child("type").append_child(pugi::node_pcdata).set_value("EOG");
9+
for (int i = 0; i < 4; ++i)
10+
channels.append_child("channel")
11+
.append_child("type")
12+
.append_child(pugi::node_pcdata)
13+
.set_value("EEG");
14+
for (int i = 0; i < 4; ++i)
15+
channels.append_child("channel")
16+
.append_child("type")
17+
.append_child(pugi::node_pcdata)
18+
.set_value("EOG");
1319

1420
INFO(info.to_fullinfo_message());
1521
REQUIRE(info.matches_query("name='streamname'"));
@@ -24,9 +30,12 @@ TEST_CASE("streaminfo matching via XPath", "[basic][streaminfo][xml]") {
2430

2531
#ifdef CATCH_CONFIG_ENABLE_BENCHMARKING
2632
// Append lots of dummy channels for performance tests
27-
for(int i=0; i<50000; ++i)
28-
channels.append_child("chn").append_child("type").append_child(pugi::node_pcdata).set_value("foobar");
29-
for(int i=0; i<2000; ++i) {
33+
for (int i = 0; i < 50000; ++i)
34+
channels.append_child("chn")
35+
.append_child("type")
36+
.append_child(pugi::node_pcdata)
37+
.set_value("foobar");
38+
for (int i = 0; i < 2000; ++i) {
3039
channels = channels.append_child("chn");
3140
channels.append_child(pugi::node_pcdata).set_value("1");
3241
}
@@ -50,5 +59,4 @@ TEST_CASE("streaminfo matching via XPath", "[basic][streaminfo][xml]") {
5059
};
5160

5261
#endif
53-
5462
}

0 commit comments

Comments
 (0)