From c0d0364c030688aa8bfe4ad8dcaa2cffed8c0d04 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 13 May 2009 16:04:14 +0000 Subject: Strip trailing whitespace. git-svn-id: http://svn.drobilla.net/lad/trunk/raul@1999 a436a847-0d15-0410-975c-d299462d15a1 --- tests/list_test.cpp | 26 +++++------ tests/midi_ringbuffer_test.cpp | 6 +-- tests/path_test.cpp | 4 +- tests/quantize_test.cpp | 6 +-- tests/queue_test.cpp | 22 ++++----- tests/ringbuffer_test.cpp | 4 +- tests/table_test.cpp | 100 ++++++++++++++++++++--------------------- tests/time_test.cpp | 6 +-- 8 files changed, 87 insertions(+), 87 deletions(-) (limited to 'tests') diff --git a/tests/list_test.cpp b/tests/list_test.cpp index c3909a1..ae139ce 100644 --- a/tests/list_test.cpp +++ b/tests/list_test.cpp @@ -38,7 +38,7 @@ int main() cout << *i << endl; } cout << endl; - + /*l.remove(1); cout << "Removed 1 (head) (by value)...\n"; @@ -60,7 +60,7 @@ int main() cout << *i << endl; } cout << endl; - + /*l.remove(5); cout << "Removed 5 (by value)...\n"; @@ -68,7 +68,7 @@ int main() cout << *i << endl; } cout << endl; - + l.remove(8); cout << "Removed 8 (tail) (by value)...\n"; @@ -97,7 +97,7 @@ int main() for (List::iterator i = r.begin(); i != r.end(); ++i) { cout << *i << endl; } - + cout << "\n\nTesting appending to an empty list:\n"; l.clear(); @@ -106,12 +106,12 @@ int main() l2.push_back(new List::Node(2)); l2.push_back(new List::Node(3)); l2.push_back(new List::Node(4)); - + cout << "l1:\n"; for (List::iterator i = l.begin(); i != l.end(); ++i) { cout << *i << endl; } - + cout << "l2:\n"; for (List::iterator i = l2.begin(); i != l2.end(); ++i) { cout << *i << endl; @@ -122,18 +122,18 @@ int main() for (List::iterator i = l.begin(); i != l.end(); ++i) { cout << *i << endl; } - + cout << "\n\nAppending non-empty lists:\n"; l2.push_back(new List::Node(5)); l2.push_back(new List::Node(6)); l2.push_back(new List::Node(7)); l2.push_back(new List::Node(8)); - + cout << "l1:\n"; for (List::iterator i = l.begin(); i != l.end(); ++i) { cout << *i << endl; } - + cout << "l2:\n"; for (List::iterator i = l2.begin(); i != l2.end(); ++i) { cout << *i << endl; @@ -144,15 +144,15 @@ int main() for (List::iterator i = l.begin(); i != l.end(); ++i) { cout << *i << endl; } - - + + cout << "\n\nAppending an empty list:\n"; - + cout << "l1:\n"; for (List::iterator i = l.begin(); i != l.end(); ++i) { cout << *i << endl; } - + cout << "l2:\n"; for (List::iterator i = l2.begin(); i != l2.end(); ++i) { cout << *i << endl; diff --git a/tests/midi_ringbuffer_test.cpp b/tests/midi_ringbuffer_test.cpp index 05a7e35..0726259 100644 --- a/tests/midi_ringbuffer_test.cpp +++ b/tests/midi_ringbuffer_test.cpp @@ -21,17 +21,17 @@ read_write_test(EventRingBuffer& rb, unsigned offset) size_t written = rb.write(t, size, buf); #endif assert(written == size); - + for (size_t i=0; i < 4; ++i) buf[i] = 0; rb.read(&t, &size, buf); - + cout << "t=" << t << ", s=" << size << ", b='" << buf << "'" << endl; } - + int main() { diff --git a/tests/path_test.cpp b/tests/path_test.cpp index ac7ff2b..20d6705 100644 --- a/tests/path_test.cpp +++ b/tests/path_test.cpp @@ -23,7 +23,7 @@ main() cerr << "Nameification:" << endl; for (list::iterator i = names.begin(); i != names.end(); ++i) cerr << *i << " -> " << Path::nameify(*i) << endl; - + cerr << endl; cerr << Path("/foo/bar") << " parent = " << Path("/foo/bar").parent() << endl; cerr << Path("/foo") << " parent = " << Path("/foo").parent() << endl; @@ -34,7 +34,7 @@ main() cerr << (Path("/").is_parent_of(Path("/foo"))) << endl; cerr << (Path("/foo").is_parent_of(Path("/foo/bar"))) << endl; cerr << !(Path("/foo").is_parent_of(Path("/foo2"))) << endl; - + cerr << endl << endl << "Descendants..." << endl; cerr << "/ /foo " << Path::descendant_comparator("/", "/foo") << endl; cerr << "/foo /foo/bar " << Path::descendant_comparator("/foo", "/foo/bar") << endl; diff --git a/tests/quantize_test.cpp b/tests/quantize_test.cpp index 49e3fbd..cc10505 100644 --- a/tests/quantize_test.cpp +++ b/tests/quantize_test.cpp @@ -13,19 +13,19 @@ main() cout << "Quantization: "; cin >> in; cout << endl; - + TimeStamp q(TimeUnit(TimeUnit::BEATS, 19200), in); while (true) { cout << "Beats: "; cin >> in; - + TimeStamp beats(TimeUnit(TimeUnit::BEATS, 19200), in); cout << "Quantized: "; cout << Quantizer::quantize(q, beats) << endl << endl; } - return 0; + return 0; } diff --git a/tests/queue_test.cpp b/tests/queue_test.cpp index 1e92104..28d06d8 100644 --- a/tests/queue_test.cpp +++ b/tests/queue_test.cpp @@ -48,7 +48,7 @@ struct WriteAction { // The victim -SRMWQueue queue(QUEUE_SIZE); +SRMWQueue queue(QUEUE_SIZE); class WriteThread : public Thread { @@ -119,7 +119,7 @@ dump_data() int main() { unsigned long total_processed = 0; - + cout << "Testing size" << endl; for (unsigned i=0; i < queue.capacity(); ++i) { queue.push(i); @@ -137,7 +137,7 @@ int main() } } } - + for (unsigned i=0; i < queue.capacity(); ++i) queue.pop(); @@ -145,7 +145,7 @@ int main() cerr << "ERROR: Should be empty" << endl; return -1; } - + cout << "Testing concurrent reading/writing" << endl; vector writers(NUM_WRITERS, new WriteThread()); @@ -177,7 +177,7 @@ int main() /*if (count > 0) cout << "Processed " << count << " requests\t\t" << "(total " << total_processed << ")\r\n";*/ - + //if (total_processed > 0 && total_processed % 128l == 0) // cout << "Total processed: " << total_processed << "\r\n"; } @@ -185,7 +185,7 @@ int main() if (tcsetattr(0, TCSANOW, &orig_term) != 0) return 1; //restore cout << "Finishing." << endl; - + // Stop the writers for (unsigned i=0; i < NUM_WRITERS; ++i) writers[i]->stop(); @@ -212,7 +212,7 @@ int main() cout << "Total processed: " << total_processed << endl; if (total_processed > INT_MAX) cout << "(Counter had to wrap)" << endl; - else + else cout << "(Counter did NOT have to wrap)" << endl; @@ -224,7 +224,7 @@ int main() cout << "FAILED BY " << diff << endl; // dump_data(); } - + dump_data(); return 0; @@ -240,7 +240,7 @@ int main() cout << "New queue. Should be empty: " << q.empty() << endl; cout << "Capacity: " << q.capacity() << endl; //cout << "Fill: " << q.fill() << endl; - + for (uint i=0; i < 5; ++i) { q.push(i); assert(!q.full()); @@ -263,7 +263,7 @@ int main() } cout << "Queue should be empty: " << q.empty() << endl; //cout << "Fill: " << q.fill() << endl; - + cout << "Attempting to add eleven elements to queue of size 10. Only first 10 should succeed:" << endl; for (uint i=20; i <= 39; ++i) { cout << i; @@ -271,7 +271,7 @@ int main() cout << " - full: " << q.full(); cout << ", succeeded: " << q.push(i) << endl; } - + return 0; } #endif diff --git a/tests/ringbuffer_test.cpp b/tests/ringbuffer_test.cpp index 162d984..87b81c6 100644 --- a/tests/ringbuffer_test.cpp +++ b/tests/ringbuffer_test.cpp @@ -23,7 +23,7 @@ int main() { RingBuffer rb(5); - + char ev[] = { 'a', 'b', 'c' }; rb.write(3, ev); @@ -34,7 +34,7 @@ main() char ev2[] = { 'd', 'e', 'f' }; rb.write(3, ev2); - + size_t read = rb.read(3, buf); if (read < 3) diff --git a/tests/table_test.cpp b/tests/table_test.cpp index d5d0610..5e83479 100644 --- a/tests/table_test.cpp +++ b/tests/table_test.cpp @@ -51,17 +51,17 @@ main(int argc, char** argv) t[20] = 20; t[21] = 21; - + cout << "Contents:" << endl; for (Table::const_iterator i = t.begin(); i != t.end(); ++i) cout << i->first << " "; cout << endl; - + std::cout << "Range " << t.begin()->first << " .. " << range_end_val << std::endl; Table::const_iterator range_begin = t.begin(); ++range_begin; ++range_begin; - + Table::iterator range_end = t.find_range_end(t.begin(), range_comparator); for (Table::const_iterator i = t.begin(); i != range_end; ++i) @@ -79,7 +79,7 @@ main(int argc, char** argv) for (Table::const_iterator i = t.begin(); i != t.end(); ++i) cout << i->first << " "; cout << endl; - + cout << "Erasing elements 0..3" << endl; first = t.begin(); last = first; @@ -89,7 +89,7 @@ main(int argc, char** argv) for (Table::const_iterator i = t.begin(); i != t.end(); ++i) cout << i->first << " "; cout << endl; - + cout << "Erasing elements end()-2..end()" << endl; last = t.end(); first = last; @@ -99,7 +99,7 @@ main(int argc, char** argv) for (Table::const_iterator i = t.begin(); i != t.end(); ++i) cout << i->first << " "; cout << endl; - + cout << "Erasing everything" << endl; first = t.begin(); last = t.end(); @@ -108,7 +108,7 @@ main(int argc, char** argv) for (Table::const_iterator i = t.begin(); i != t.end(); ++i) cout << i->first << " "; cout << endl; - + /* **** */ PathTable pt; @@ -122,12 +122,12 @@ main(int argc, char** argv) pt.insert(make_pair("/bar/buzz/WHAT", 'c')); pt.insert(make_pair("/bar/buzz/WHHHhhhhhAT", 'c')); pt.insert(make_pair("/quux", 'a')); - + cout << "Paths: " << endl; for (PathTable::const_iterator i = pt.begin(); i != pt.end(); ++i) cout << i->first << " "; cout << endl; - + PathTable::const_iterator descendants_begin = pt.begin(); size_t begin_index = rand() % pt.size(); for (size_t i=0; i < begin_index; ++i) @@ -147,14 +147,14 @@ main(int argc, char** argv) assert(quux_end != quux); SharedPtr< Table > yanked = pt.yank(quux, quux_end); - + cout << "Yanked " << yank_path << endl; for (PathTable::const_iterator i = pt.begin(); i != pt.end(); ++i) cout << i->first << " "; cout << endl; pt.cram(*yanked.get()); - + cout << "Crammed " << yank_path << endl; for (PathTable::const_iterator i = pt.begin(); i != pt.end(); ++i) cout << i->first << " "; @@ -164,7 +164,7 @@ main(int argc, char** argv) cout << "\nAssuming you built with debugging, if this continues to run " << "and chews your CPU without dying, everything's good." << endl; - + Table st; @@ -175,7 +175,7 @@ main(int argc, char** argv) //st["zeta"] = "one"; st.erase("banana"); - + for (Table::const_iterator i = t.begin(); i != t.end(); ++i) cout << i->first << " "; cout << endl; @@ -235,88 +235,88 @@ benchmark(size_t n) timeval t1; t1.tv_sec=0; t1.tv_usec=0; - + timeval t2; t2.tv_sec=0; t2.tv_usec=0; - + /** std::map **/ std::map m; gettimeofday(&t1, NULL); - + for (size_t i=0; i < n; ++i) m.insert(make_pair(values[i], i)); - + gettimeofday(&t2, NULL); float delta_t = (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) * 0.000001f; cout << "std::map time to insert " << n << " values: \t" << delta_t << endl; - + gettimeofday(&t1, NULL); - + for (size_t i=0; i < n; ++i) useless_accumulator += m.find(values[i])->second; - + gettimeofday(&t2, NULL); delta_t = (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) * 0.000001f; cout << "std::map time to lookup " << n << " values: \t" << delta_t << endl; - - + + /** std::set **/ std::set s; gettimeofday(&t1, NULL); - + for (size_t i=0; i < n; ++i) s.insert(values[i]); - + gettimeofday(&t2, NULL); delta_t = (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) * 0.000001f; cout << "std::set time to insert " << n << " values: \t" << delta_t << endl; - + gettimeofday(&t1, NULL); - + for (size_t i=0; i < n; ++i) useless_accumulator += (int)(*s.find(values[i]))[0]; - + gettimeofday(&t2, NULL); delta_t = (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) * 0.000001f; cout << "std::set time to lookup " << n << " values: \t" << delta_t << endl; - - + + /** sorted std::vector **/ /*std::vector v; gettimeofday(&t1, NULL); - + for (size_t i=0; i < n; ++i) v.push_back(values[i]); sort(v.begin(), v.end()); - + gettimeofday(&t2, NULL); delta_t = (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) * 0.000001f; cout << "std::vector (sorted) time to insert " << n << " values: \t" << delta_t << endl; - + gettimeofday(&t1, NULL); - + for (size_t i=0; i < n; ++i) useless_accumulator += *lower_bound(v.begin(), v.end(), values[i]); - + gettimeofday(&t2, NULL); delta_t = (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) * 0.000001f; @@ -325,55 +325,55 @@ benchmark(size_t n) /** Raul::Table **/ - + Raul::Table t(n); - + gettimeofday(&t1, NULL); - + for (size_t i=0; i < n; ++i) t.insert(make_pair(values[i], i)); - + gettimeofday(&t2, NULL); delta_t = (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) * 0.000001f; cout << "Raul::Table time to insert " << n << " values: " << delta_t << endl; - + gettimeofday(&t1, NULL); - + for (size_t i=0; i < n; ++i) useless_accumulator += t.find(values[i])->second; - + gettimeofday(&t2, NULL); delta_t = (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) * 0.000001f; cout << "Raul::Table time to lookup " << n << " values: \t" << delta_t << endl; - - + + #ifdef WITH_TR1 /** boost::hash && std::unordered_map **/ - + tr1::unordered_map > um; gettimeofday(&t1, NULL); - + um.rehash(n); - + for (size_t i=0; i < n; ++i) um.insert(make_pair(values[i], i)); - + gettimeofday(&t2, NULL); delta_t = (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) * 0.000001f; cout << "tr1::unordered_map + boost::hash time to insert " << n << " values: \t" << delta_t << endl; - + gettimeofday(&t1, NULL); - + for (size_t i=0; i < n; ++i) useless_accumulator += um.find(values[i])->second; - + gettimeofday(&t2, NULL); delta_t = (t2.tv_sec - t1.tv_sec) + (t2.tv_usec - t1.tv_usec) * 0.000001f; diff --git a/tests/time_test.cpp b/tests/time_test.cpp index 4757f6b..2b53207 100644 --- a/tests/time_test.cpp +++ b/tests/time_test.cpp @@ -15,18 +15,18 @@ main() double in_double; cout << "Beats: "; cin >> in_double; - + TimeStamp t(unit, (uint32_t)in_double, (uint32_t)((in_double - (uint32_t)in_double) * unit.ppt())); cout << "\tSeconds: "; cout << ts.beats_to_seconds(t); cout << endl; - + cout << "\tTicks: "; cout << ts.beats_to_ticks(t); cout << endl; - return 0; + return 0; } -- cgit v1.2.1