Author: sebor
Date: Thu Jan 5 17:35:51 2006
New Revision: 366384
URL: http://svn.apache.org/viewcvs?rev=366384&view=rev
Log:
2006-01-05 Martin Sebor <[EMAIL PROTECTED]>
* 21.string.push_back.mt.cpp: Removed an unnecessary #include directive.
(to_append): Removed the size of the array and relied on its initializer
instead.
(ehread_func): Asserted that array index is in bounds and replaced uses
of the assert() macro with RW_ASSERT().
(thread_func): Parenthesized a call to putc in order to thwart macro
expansion and qualified size_t with the name of the declaring namespace.
Modified:
incubator/stdcxx/trunk/tests/strings/21.string.push_back.mt.cpp
Modified: incubator/stdcxx/trunk/tests/strings/21.string.push_back.mt.cpp
URL:
http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/tests/strings/21.string.push_back.mt.cpp?rev=366384&r1=366383&r2=366384&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/strings/21.string.push_back.mt.cpp (original)
+++ incubator/stdcxx/trunk/tests/strings/21.string.push_back.mt.cpp Thu Jan 5
17:35:51 2006
@@ -20,21 +20,20 @@
*
**************************************************************************/
-#include <string>
+#include <string> // for string
-#include <cassert> // for assert
-#include <cstdio> // for puts
+#include <cstdio> // for putc(), puts(), ...
-#include <driver.h> // for rw_test
-#include <rwthread.h> // for rw_thread_pool
-#include <valcmp.h> // for rw_equal
+#include <driver.h> // for rw_test()
+#include <rwthread.h> // for rw_thread_pool()
+#include <valcmp.h> // for rw_strncmp()
/**************************************************************************/
#define MAX_THREADS 32
#define MAX_LOOPS 100000
-const char to_append [MAX_THREADS + 1] = {
+const char to_append [] = {
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
};
@@ -56,6 +55,8 @@
// compute an index unique to this thread
const std::size_t thr_inx = std::size_t (pthread->threadno) % MAX_THREADS;
+ RW_ASSERT (thr_inx < sizeof to_append);
+
// compute the expected strings unique to this thread
const std::string expect0 = shared0 + to_append [thr_inx];
const std::string expect1 = shared1 + to_append [thr_inx];
@@ -68,7 +69,7 @@
const char* const expect1_data = expect1.data ();
const std::size_t expect1_len = expect1.length ();
- for (size_t i = 0; i != std::size_t (rw_opt_nloops); ++i) {
+ for (std::size_t i = 0; i != std::size_t (rw_opt_nloops); ++i) {
// create copies of global strings
std::string local0 (shared0);
@@ -79,15 +80,16 @@
local1.push_back (to_append [thr_inx]);
// verify that the local copies have the expected length
- assert (expect0_len == local0.length ());
- assert (expect1_len == local1.length ());
+ RW_ASSERT (expect0_len == local0.length ());
+ RW_ASSERT (expect1_len == local1.length ());
// verify that the local copies have the expected data
- assert (0 == rw_strncmp (expect0_data, local0.data ()));
- assert (0 == rw_strncmp (expect1_data, local1.data ()));
+ RW_ASSERT (0 == rw_strncmp (expect0_data, local0.data ()));
+ RW_ASSERT (0 == rw_strncmp (expect1_data, local1.data ()));
if (60 < rw_opt_nloops && 0 == i % (rw_opt_nloops / 60)) {
- std::putc (to_append [thr_inx], stdout);
+ // parentheses used to thwart macro expansion
+ (std::putc)(to_append [thr_inx], stdout);
std::fflush (stdout);
}
}