From b8f87a5b55387ad7b698742dcfcc1bc93538a053 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 5 Feb 2010 21:19:56 +0000 Subject: Convert C-style casts to C++ style casts. git-svn-id: http://svn.drobilla.net/lad/trunk/raul@2432 a436a847-0d15-0410-975c-d299462d15a1 --- test/midi_ringbuffer_test.cpp | 9 ++++++--- test/queue_test.cpp | 2 +- test/smf_test.cpp | 2 +- test/table_test.cpp | 4 ++-- test/time_test.cpp | 4 ++-- 5 files changed, 12 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/midi_ringbuffer_test.cpp b/test/midi_ringbuffer_test.cpp index f75cfd5..a5173b4 100644 --- a/test/midi_ringbuffer_test.cpp +++ b/test/midi_ringbuffer_test.cpp @@ -17,15 +17,18 @@ read_write_test(EventRingBuffer& rb, unsigned offset) unsigned char write_buf[5]; unsigned char read_buf[5]; - snprintf((char*)write_buf, 5, "%d", offset); - size = strlen((char*)write_buf); + snprintf(static_cast(write_buf), 5, "%d", offset); + size = strlen(static_cast(write_buf)); const size_t written = rb.write(t, size, write_buf); assert(written == size); rb.read(&t, &size, read_buf); - return (strncmp((const char*)write_buf, (const char*)read_buf, size)); + return strncmp( + static_cast(write_buf), + static_cast(read_buf), + size); } diff --git a/test/queue_test.cpp b/test/queue_test.cpp index 49ba6f2..329ec60 100644 --- a/test/queue_test.cpp +++ b/test/queue_test.cpp @@ -135,7 +135,7 @@ main() vector writers(NUM_WRITERS, new WriteThread()); for (unsigned i=0; i < NUM_WRITERS; ++i) { - writers[i]->set_name(string("Writer ") + (char)('0' + i)); + writers[i]->set_name(string("Writer ") + static_cast('0' + i)); writers[i]->start(); } diff --git a/test/smf_test.cpp b/test/smf_test.cpp index 9ff27f5..e848f15 100644 --- a/test/smf_test.cpp +++ b/test/smf_test.cpp @@ -55,7 +55,7 @@ main(int argc, char** argv) cout << ":\t"; cout.flags(ios::hex); for (uint32_t i=0; i < ev_size; ++i) { - cout << "0x" << (int)buf[i] << " "; + cout << "0x" << static_cast(buf[i]) << " "; } cout.flags(ios::dec); cout << endl; diff --git a/test/table_test.cpp b/test/table_test.cpp index 882873a..41d13c2 100644 --- a/test/table_test.cpp +++ b/test/table_test.cpp @@ -186,7 +186,7 @@ main(int argc, char** argv) t.insert(make_pair(val, ((val + 3) * 17))); } - for (int i=0; i < (int)table_size; ++i) { + for (size_t i=0; i < table_size; ++i) { int val = rand()%100; Table::iterator iter = t.find(val); assert(iter == t.end() || iter->second == (val + 3) * 17); @@ -281,7 +281,7 @@ benchmark(size_t n) gettimeofday(&t1, NULL); for (size_t i=0; i < n; ++i) - useless_accumulator += (int)(*s.find(values[i]))[0]; + useless_accumulator += static_cast((*s.find(values[i]))[0]); gettimeofday(&t2, NULL); diff --git a/test/time_test.cpp b/test/time_test.cpp index a7479be..b48e3f1 100644 --- a/test/time_test.cpp +++ b/test/time_test.cpp @@ -14,8 +14,8 @@ main() double in_double = 2.5; - TimeStamp t(unit, (uint32_t)in_double, - (uint32_t)((in_double - (uint32_t)in_double) * unit.ppt())); + TimeStamp t(unit, static_cast(in_double), + static_cast((in_double - static_cast(in_double)) * unit.ppt())); cout << "\tSeconds: "; cout << ts.beats_to_seconds(t); -- cgit v1.2.1