44 std::size_t bufsize = 0;
45 std::size_t nelems = 0;
59 const double val = std::strtod (
s, &
end);
61 unsigned long repeat = 1;
67 repeat = std::strtoul (++
end, &
e, 10);
70 for (;
' ' == *
end; ++
end);
82 for (;
' ' == *
end; ++
end);
94 if (nelems == bufsize) {
97 const std::size_t newsize = (bufsize + 1) * 2;
98 T*
const tmp =
new T [newsize];
101 for (std::size_t
i = 0;
i != nelems; ++
i)
135const std::size_t*
count (
const T*) {
return 0; }
149 for (std::size_t
i = 0;
i != nelems; ++
i)
150 (
a +
i)->~UserClass ();
161 std::size_t bufsize = 0;
162 std::size_t nelems = 0;
176 const double val = std::strtod (
s, &
end);
178 unsigned long repeat = 1;
184 repeat = std::strtoul (++
end, &
e, 10);
187 for (;
' ' == *
end; ++
end);
199 for (;
' ' == *
end; ++
end);
211 if (nelems == bufsize) {
214 void*
const raw =
operator new ((bufsize + 1) * 2 *
size);
217 for (std::size_t
i = 0;
i != nelems; ++
i)
220 bufsize = (bufsize + 1) * 2;
249 (std::valarray<T>::*op_assign)(const
std::valarray<
T>&),
257 std::size_t nelems = 0;
262 const T*
const lhs_array =
make_array ((
const T*)0, lhs_str, &nelems);
280 std::valarray<T> lhs_va (lhs_array, nelems);
281 const std::valarray<T> rhs_va (rhs_array, nelems);
284 std::size_t
size = 0;
288 const std::size_t*
const pcounter =
count ((
const T*)0);
292 std::size_t nobjects = pcounter ? *pcounter : 0;
297 "valarray<%s>(%s) %s std::valarray<%1$s>(%s)",
298 tname, lhs_str, opname, rhs_str);
301 std::valarray<T> &
res = (lhs_va.*op_assign)(rhs_va);
305 "line %d == %#p, got %#p",
306 __LINE__, fname, &lhs_va, &
res);
311 "line %d. %s.size() == %zu, got %zu",
312 __LINE__, fname, nelems, lhs_va.size ());
316 nobjects = *pcounter - nobjects;
319 "line %d. %s constucted %zu objects, expected %zu",
320 __LINE__, fname, nobjects, nelems);
324 for (std::size_t
i = 0;
i != nelems; ++
i) {
326 "line %d. %s: element at index %zu == %d, got %d",
327 __LINE__, fname,
i,
value (res_array [
i]),
342#define OP(lhs, rhs, res) \
343 test_op_assign ((T*)0, op, tname, opname, __LINE__, lhs, rhs, res)
350 "std::valarray<%s>::operator%s (const std::valarray<%1$s>&)",
353 std::valarray<T>& (std::valarray<T>::*op)(
const std::valarray<T>&) =
354 &std::valarray<T>::operator*=;
364 OP (
"1,2",
"1,1",
"1,2");
365 OP (
"1,2",
"1,2",
"1,4");
366 OP (
"2,3",
"4,5",
"8,15");
367 OP (
"3,4",
"5,6",
"15,24");
369 OP (
"1,2,3",
"4,5,6",
"4,10,18");
370 OP (
"-1,-2,-3",
"-4,-5,-6",
"4,10,18");
371 OP (
"1,-2,3",
"-4,5,-6",
"-4,-10,-18");
380 "std::valarray<%s>::operator%s (const std::valarray<%1$s>&)",
383 std::valarray<T>& (std::valarray<T>::*op)(
const std::valarray<T>&) =
384 &std::valarray<T>::operator/=;
393 OP (
"3",
"2",
"1.5");
396 OP (
"0,1,2,3,4,5,6,7",
"1,1,1,1,1,1,1,1",
"0,1,2,3,4,5,6,7");
397 OP (
"2,4,6,8,10,12,14,16",
"2,2,2,2,2,2,2,2",
"1,2,3,4,5,6,7,8");
398 OP (
"2,4,6,8,10,12,14,16",
"2,2,2,2,2,2,2,2",
"1,2,3,4,5,6,7,8");
400 OP (
"0@127",
"1@127",
"0@127");
401 OP (
"1@128",
"1@128",
"1@128");
402 OP (
"2@255",
"1@255",
"2@255");
403 OP (
"2@256",
"2@256",
"1@256");
404 OP (
"3@256",
"1@256",
"3@256");
405 OP (
"3@511",
"2@511",
"1.5@511");
406 OP (
"4@512",
"2@512",
"2@512");
415 "std::valarray<%s>::operator%s (const std::valarray<%1$s>&)",
418 std::valarray<T>& (std::valarray<T>::*op)(
const std::valarray<T>&) =
419 &std::valarray<T>::operator%=;
435 OP (
"0,1",
"2,2",
"0,1");
436 OP (
"1,2,3",
"4,4,4",
"1,2,3");
437 OP (
"2,3,4,5",
"6,6,6,6",
"2,3,4,5");
439 OP (
"0,1,2,3,4,5,6,7,8,9",
"10,9,8,7,6,5,4,3,2,1",
"0,1,2,3,4,0,2,1,0,0");
442#define CANNOT_TEST(T, name) \
443 void test_##name (const T*, const char*, const char*) { } \
444 typedef void swallow_semicolon
457 "std::valarray<%s>::operator%s (const std::valarray<%1$s>&)",
460 std::valarray<T>& (std::valarray<T>::*op)(
const std::valarray<T>&) =
461 &std::valarray<T>::operator+=;
471 OP (
"0@31",
"0@31",
"0@31");
472 OP (
"0@31",
"1@31",
"1@31");
473 OP (
"1@31",
"0@31",
"1@31");
474 OP (
"1@31",
"-1@31",
"0@31");
475 OP (
"-1@31",
"1@31",
"0@31");
477 OP (
"2@32",
"3@32",
"5@32");
478 OP (
"3@32",
"5@32",
"8@32");
479 OP (
"5@32",
"7@32",
"12@32");
480 OP (
"9@32",
"-9@32",
"0@32");
482 OP (
"0@63",
"0@63",
"0@63");
483 OP (
"0@63",
"1@63",
"1@63");
484 OP (
"1@63",
"0@63",
"1@63");
485 OP (
"1@63",
"-1@63",
"0@63");
486 OP (
"-1@63",
"1@63",
"0@63");
488 OP (
"0@63",
"0@63",
"0@63");
489 OP (
"0@63",
"1@63",
"1@63");
490 OP (
"1@63",
"0@63",
"1@63");
491 OP (
"1@63",
"-1@63",
"0@63");
492 OP (
"-1@63",
"1@63",
"0@63");
494 OP (
"0,0",
"0,0",
"0,0");
495 OP (
"0,0",
"0,1",
"0,1");
496 OP (
"0,0",
"1,0",
"1,0");
497 OP (
"0,0",
"1,1",
"1,1");
498 OP (
"0,1",
"0,1",
"0,2");
499 OP (
"0,1",
"1,0",
"1,1");
500 OP (
"0,1",
"1,1",
"1,2");
501 OP (
"1,0",
"0,0",
"1,0");
502 OP (
"1,0",
"0,1",
"1,1");
503 OP (
"1,0",
"1,0",
"2,0");
504 OP (
"1,0",
"1,1",
"2,1");
505 OP (
"1,1",
"0,0",
"1,1");
506 OP (
"1,1",
"0,1",
"1,2");
507 OP (
"1,1",
"1,0",
"2,1");
508 OP (
"1,1",
"1,1",
"2,2");
517 "std::valarray<%s>::operator%s (const std::valarray<%1$s>&)",
520 std::valarray<T>& (std::valarray<T>::*op)(
const std::valarray<T>&) =
521 &std::valarray<T>::operator-=;
525 OP (
" 0",
" 0",
" 0");
526 OP (
" 0",
"+1",
"-1");
527 OP (
"+1",
" 0",
"+1");
528 OP (
"+1",
"-1",
"+2");
529 OP (
"-1",
"+1",
"-2");
531 OP (
" 0@12",
" 0@12",
" 0@12");
532 OP (
" 0@23",
"+1@23",
"-1@23");
533 OP (
"+1@34",
" 0@34",
"+1@34");
534 OP (
"+1@45",
"-1@45",
"+2@45");
535 OP (
"-1@56",
"+1@56",
"-2@56");
544 "std::valarray<%s>::operator%s (const std::valarray<%1$s>&)",
547 std::valarray<T>& (std::valarray<T>::*op)(
const std::valarray<T>&) =
548 &std::valarray<T>::operator^=;
561 OP (
"0@10",
"0@10",
"0@10");
562 OP (
"0@11",
"1@11",
"1@11");
563 OP (
"1@12",
"0@12",
"1@12");
564 OP (
"1@13",
"1@13",
"0@13");
565 OP (
"3@14",
"0@14",
"3@14");
566 OP (
"3@15",
"1@15",
"2@15");
567 OP (
"3@16",
"2@16",
"1@16");
568 OP (
"3@17",
"3@17",
"0@17");
581 "std::valarray<%s>::operator%s (const std::valarray<%1$s>&)",
584 std::valarray<T>& (std::valarray<T>::*op)(
const std::valarray<T>&) =
585 &std::valarray<T>::operator&=;
598 OP (
"0@10",
"0@10",
"0@10");
599 OP (
"0@11",
"1@11",
"0@11");
600 OP (
"1@12",
"0@12",
"0@12");
601 OP (
"1@13",
"1@13",
"1@13");
602 OP (
"3@14",
"0@14",
"0@14");
603 OP (
"3@15",
"1@15",
"1@15");
604 OP (
"3@16",
"2@16",
"2@16");
605 OP (
"3@17",
"3@17",
"3@17");
618 "std::valarray<%s>::operator%s (const std::valarray<%1$s>&)",
621 std::valarray<T>& (std::valarray<T>::*op)(
const std::valarray<T>&) =
622 &std::valarray<T>::operator|=;
635 OP (
"0@10",
"0@10",
"0@10");
636 OP (
"0@11",
"1@11",
"1@11");
637 OP (
"1@12",
"0@12",
"1@12");
638 OP (
"1@13",
"1@13",
"1@13");
639 OP (
"3@14",
"0@14",
"3@14");
640 OP (
"3@15",
"1@15",
"3@15");
641 OP (
"3@16",
"2@16",
"3@16");
642 OP (
"3@17",
"3@17",
"3@17");
655 "std::valarray<%s>::operator%s (const std::valarray<%1$s>&)",
658 std::valarray<T>& (std::valarray<T>::*op)(
const std::valarray<T>&) =
659 &std::valarray<T>::operator<<=;
672 OP (
"0@10",
"0@10",
"0@10");
673 OP (
"0@11",
"1@11",
"0@11");
674 OP (
"1@12",
"0@12",
"1@12");
675 OP (
"1@13",
"1@13",
"2@13");
676 OP (
"3@14",
"0@14",
"3@14");
677 OP (
"3@15",
"1@15",
"6@15");
678 OP (
"3@16",
"2@16",
"12@16");
679 OP (
"3@17",
"3@17",
"24@17");
692 "std::valarray<%s>::operator%s (const std::valarray<%1$s>&)",
695 std::valarray<T>& (std::valarray<T>::*op)(
const std::valarray<T>&) =
696 &std::valarray<T>::operator>>=;
709 OP (
"0@21",
"0@21",
"0@21");
710 OP (
"0@21",
"1@21",
"0@21");
711 OP (
"1@21",
"0@21",
"1@21");
712 OP (
"2@21",
"1@21",
"1@21");
713 OP (
"3@21",
"0@21",
"3@21");
714 OP (
"6@21",
"1@21",
"3@21");
715 OP (
"12@21",
"2@21",
"3@21");
716 OP (
"24@21",
"3@21",
"3@21");
745 const std::size_t nassigns =
sizeof opt_assign /
sizeof *opt_assign;
746 for (std::size_t
i = 0;
i != nassigns; ++
i) {
747 if (0 < opt_assign [
i]) {
748 for (std::size_t
j = 0;
j != nassigns; ++
j) {
749 if (0 == opt_assign [
j])
757 "tests of operator*= disabled"))
761 "tests of operator/= disabled"))
765 "tests of operator%= disabled"))
769 "tests of operator+= disabled"))
773 "tests of operator-= disabled"))
777 "tests of operator^= disabled"))
781 "tests of operator&= disabled"))
785 "tests of operator|= disabled"))
789 "tests of operator<<= disabled"))
793 "tests of operator>>= disabled"))
803#define TEST(T) test_op_assign ((const T*)0, #T)
808#if 0x05000000 > _RWSTD_VER
813 "test of UserClass disabled in stdcxx 4.2.0 and prior "
814 "due to STDCXX-512");
827int main (
int argc,
char *argv[])
830 return rw_test (argc, argv, __FILE__,
void run_test(const ForwardIterator &dummy, T *, Predicate *pred)
void test_or_assign(const T *, const char *tname, const char *opname)
const std::size_t * count(const T *)
void test_and_assign(const T *, const char *tname, const char *opname)
#define CANNOT_TEST(T, name)
T * make_array(const T *, const char *s, std::size_t *psize)
void test_op_assign(const T *, std::valarray< T > &(std::valarray< T >::*op_assign)(const std::valarray< T > &), const char *tname, const char *opname, int line, const char *lhs_str, const char *rhs_str, const char *res_str)
void test_xor_assign(const T *, const char *tname, const char *opname)
void test_mul_assign(const T *, const char *tname, const char *opname)
#define OP(lhs, rhs, res)
void delete_array(const T *array, std::size_t)
void test_mod_assign(const T *, const char *tname, const char *opname)
void test_shl_assign(const T *, const char *tname, const char *opname)
void test_div_assign(const T *, const char *tname, const char *opname)
void test_shr_assign(const T *, const char *tname, const char *opname)
void test_add_assign(const T *, const char *tname, const char *opname)
void test_sub_assign(const T *, const char *tname, const char *opname)
#define _RWSTD_STATIC_CAST(T, x)
#define _RWSTD_CONST_CAST(T, x)
_TEST_EXPORT int rw_test(int argc, char *argv[], const char *filename, const char *clause, const char *comment, int(*testfun)(int, char **), const char *optspec,...)
_TEST_EXPORT int rw_info(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_note(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_warn(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_asnprintf(char **pbuf, _RWSTD_SIZE_T *pbufsize, const char *fmt,...)
static _RWSTD_SIZE_T count_