summaryrefslogtreecommitdiffstats
path: root/test/queue_test.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-12-16 10:30:44 +0100
committerDavid Robillard <d@drobilla.net>2017-12-16 10:30:44 +0100
commitfc22583b1174c9b5e6d0364240431eaca932440d (patch)
tree4d7ac03769a3860c07563621197825cfab14244e /test/queue_test.cpp
parent4db870b2b20b0a608ec0283139056b836c5b1624 (diff)
downloadraul-fc22583b1174c9b5e6d0364240431eaca932440d.tar.gz
raul-fc22583b1174c9b5e6d0364240431eaca932440d.tar.bz2
raul-fc22583b1174c9b5e6d0364240431eaca932440d.zip
Fix various warnings
Diffstat (limited to 'test/queue_test.cpp')
-rw-r--r--test/queue_test.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/test/queue_test.cpp b/test/queue_test.cpp
index 55b8c76..8f9ab61 100644
--- a/test/queue_test.cpp
+++ b/test/queue_test.cpp
@@ -31,10 +31,12 @@
using namespace std;
using namespace Raul;
-static const unsigned NUM_DATA = 10;
-static const unsigned QUEUE_SIZE = 128;
-static const unsigned NUM_WRITERS = 2;
-static const unsigned PUSHES_PER_ITERATION = 3;
+namespace {
+
+const unsigned NUM_DATA = 10;
+const unsigned QUEUE_SIZE = 128;
+const unsigned NUM_WRITERS = 2;
+const unsigned PUSHES_PER_ITERATION = 3;
// Data to read/write using actions pumped through the queue
struct Record {
@@ -52,7 +54,7 @@ struct WriteAction {
inline void read() const {
++(data[index].read_count);
- };
+ }
unsigned index;
};
@@ -60,12 +62,12 @@ struct WriteAction {
// The victim
SRMWQueue<WriteAction> queue(QUEUE_SIZE);
-static void
+void
test_write(bool* exit_flag)
{
while (!*exit_flag) {
for (unsigned j=0; j < PUSHES_PER_ITERATION; ++j) {
- unsigned i = rand() % NUM_DATA;
+ unsigned i = unsigned(rand()) % NUM_DATA;
if (queue.push(WriteAction(i))) {
++(data[i].write_count);
//cout << "WRITE " << i << "\r\n";
@@ -76,29 +78,31 @@ test_write(bool* exit_flag)
}
cout << "Writer exiting." << endl;
-};
+}
// Returns 0 if all read count/write count pairs are equal,
// otherwise how far off total count was
-static unsigned
+unsigned
data_is_sane()
{
unsigned ret = 0;
for (unsigned i = 0; i < NUM_DATA; ++i) {
- unsigned diff = abs(data[i].read_count.load() - data[i].write_count.load());
- ret += diff;
+ ret += unsigned(abs(data[i].read_count.load() -
+ data[i].write_count.load()));
}
return ret;
}
+} // namespace
+
int
main()
{
size_t total_processed = 0;
cout << "Testing size" << endl;
- for (size_t i=0; i < queue.capacity(); ++i) {
+ for (unsigned i = 0; i < queue.capacity(); ++i) {
queue.push(i);
if (i == queue.capacity()-1) {
if (!queue.full()) {
@@ -185,15 +189,11 @@ main()
cout << "(Counter did NOT have to wrap)" << endl;
const unsigned diff = data_is_sane();
-
- if (diff == 0) {
- return EXIT_SUCCESS;
- } else {
+ if (diff != 0) {
cout << "FAILED BY " << diff << endl;
- return EXIT_FAILURE;
}
- return 0;
+ return diff == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
#if 0