38#define Swap(sig) ListIds::swap_ ## sig
40static const char*
const exceptions[] = {
41 "unknown exception",
"bad_alloc",
"exception"
49cont_cont_test_cases [] = {
52#define TEST(str, arg) \
53 { __LINE__, -1, -1, -1, -1, -1, \
54 str, sizeof str - 1, arg, sizeof arg - 1, \
84 TEST (
"a<U0>b<U0>@2c",
"<U0>b<U0>@2c"),
85 TEST (
"<U0>b<U0>@2c",
"a<U0>b<U0>@2c"),
87 TEST (
"a<U0>b<U0>@2c",
"<U0>@2"),
88 TEST (
"<U0>@2",
"a<U0>b<U0>@2c"),
92 TEST (
"x@4096",
"<U0>@3"),
93 TEST (
"<U0>@3",
"x@4096"),
94 TEST (
"x@4096",
"x@4096"),
97 TEST (
"x@207",
"x@128"),
98 TEST (
"x@128",
"x@334"),
99 TEST (
"x@873",
"x@334"),
100 TEST (
"x@1412",
"x@540"),
101 TEST (
"x@540",
"x@2284"),
102 TEST (
"x@3695",
"x@2284"),
103 TEST (
"x@3695",
"x@128"),
108 TEST (
"a<U0>b<U0>@2c", 0),
113 TEST (0,
"abc@1024"),
114 TEST (0,
"a<U0>b<U0>@2c"),
117 TEST (
"last",
"test")
126typedef std::list<ListValueType, ListAllocator>
ListType;
128static int list_swap_called;
147 static bool tested =
false;
155 "Testing std::swap (std::list&, std::list&) "
156 "calls std::list::swap");
160 &std::swap<ListValueType, ListAllocator>;
167 std::swap (lst, lst);
169 rw_assert (1 == list_swap_called, 0, __LINE__,
170 "std::swap (std::list<T, A>&, std::list<T, A>&) called "
171 "std::list<T, A>::swap (std::list<T, A>&) exactly once; "
172 "got %d times", list_swap_called);
177template <
class T,
class Allocator>
183 typedef std::list <T, Allocator> List;
194 List& arg_list = tcase.
arg ? dst_list : src_list;
208 std::size_t throw_count;
209 for (throw_count = 0; ; ++throw_count) {
211 const char* expected = 0;
214#ifndef _RWSTD_NO_EXCEPTIONS
221 expected = exceptions [1];
245 src_list.swap (arg_list);
247 if (is_class &&
a1 ==
a2) {
254 "line %d. %{$FUNCALL}: complexity: %zu def ctors, "
255 "%zu copy ctors, %zu assigns", __LINE__,
261 if (0 == tcase.
str) {
264 "line %d. %{$FUNCALL}: expected 0 size, "
265 "got %zu", __LINE__, arg_list.size ());
271 __LINE__, tcase.
line,
"swap");
274 __LINE__, tcase.
line,
"swap");
278#ifndef _RWSTD_NO_EXCEPTIONS
283 "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
284 "unexpectedly%{;} caught std::%s(%#s)",
285 __LINE__, 0 != expected, expected,
caught, ex.what ());
290 "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
291 "unexpectedly%{;} caught std::%s(%#s)",
292 __LINE__, 0 != expected, expected,
caught, ex.what ());
297 "line %d. %{$FUNCALL} %{?}expected %s,%{:}"
298 "unexpectedly%{;} caught %s",
299 __LINE__, 0 != expected, expected,
caught);
307 std::size_t (-1), std::size_t (-1));
310 std::size_t (-1), std::size_t (-1));
328 else if (0 < tcase.
bthrow) {
330 "line %d. %{$FUNCALL} %{?}expected %s, caught %s"
331 "%{:}unexpectedly caught %s%{;}",
339 const std::size_t expect_throws = 0;
342 "line %d: %{$FUNCALL}: expected exactly 0 %s exception "
343 "while the swap, got %zu",
344 __LINE__, exceptions [1], throw_count);
356 return std::allocator<T>();
359template <
class T,
class Types>
367template <
class T,
class Allocator>
397int main (
int argc,
char** argv)
404 Swap (sig), sig ## _test_cases, \
405 sizeof sig ## _test_cases / sizeof *sig ## _test_cases, \
412 const std::size_t test_count =
sizeof tests /
sizeof *tests;
418 test_swap_func_array, tests, test_count);
std::allocator< ListValueType > ListAllocator
std::list< ListValueType, ListAllocator > ListType
std::allocator< T > make_alloc(SharedAlloc &, std::allocator< T > *)
#define _RWSTD_UNUSED(arg)
#define _RWSTD_NAMESPACE(name)
#define _RWSTD_SPECIALIZED_FUNCTION
const ContainerFunc & func_
const ContainerTestCase & tcase_
_TEST_EXPORT void rw_check_leaks(const SharedAlloc *=0, int=0, _RWSTD_SIZE_T=0, _RWSTD_SIZE_T=_RWSTD_SIZE_MAX)
_TEST_EXPORT int rw_run_cont_test(int, char **, const char *, const char *, ContainerIds::ContainerId, ContainerTestFunc *, const ContainerTest *, _RWSTD_SIZE_T)
#define DEFINE_CONTAINER_TEST_FUNCTIONS(fname)
_TEST_EXPORT int rw_info(int, const char *, int, const char *,...)
_TEST_EXPORT int rw_assert(int, const char *, int, const char *,...)
_TEST_EXPORT rwt_free_store * rwt_get_free_store(rwt_free_store *)
void assert_equal(const ListState &state, int line, int case_line, const char *when) const
static SharedAlloc * instance(SharedAlloc *=0)
_RWSTD_SIZE_T throw_at_calls_[n_funs]
static _RWSTD_SIZE_T n_total_op_assign_
static void reset_totals()
static _RWSTD_SIZE_T n_total_def_ctor_
static _RWSTD_SIZE_T n_total_copy_ctor_
_RWSTD_SIZE_T * throw_at_calls_[2]
_RWSTD_SIZE_T new_calls_[2]